Let's talk about Git.⚡

Git is the only thing that's it's common in our field. 99% of developers use it.

So you should learn it. At least the basics. And use it. On all your projects.

Let's start the thread.🧵

#100DaysOfCode #git #github #javascript #CodeNewbie #js
⭐ What is Git?

Git is a version-control system for tracking changes.

This allows you to save different versions of your projects and come back to them when necessary.

This also allows you to work in a team in a much better, organized way. ⬇
⭐ First steps.

On your project, your first command should be:

git init

This will initialize a new repository, this repository is a hidden folder called .git that tracks the changes made to files in your project and builds a history over time. ⬇
⭐ Stage your changes.

Every file will start as "untracked", you need to stage them, this means to tell git you want to save these changes.

To stage all files:

git add .

Don't forget the ".", this means "all", you can also write the name of the file you want to stage. ⬇
⭐ Commit your changes.

The next step will be to save these changes, for this, you write:

git commit -m "First commit"

"-m" means you want to add a message, and in between quotation marks, you explain what you did. Usually, this message is written in present tense. ⬇
⭐ Commit often.

One mistake I often see many junior developers do is not commit enough.

You don't need to commit on every little thing that you changed, but you should have a couple of things in mind. ⬇
⭐ Commit when it works.

If you changed stuff and it works, even if the code is not perfect yet, commit it.

Don't risk changing something and then having it not work. ⬇
⭐ Separate your commits by topic.

Imagine you are adding a new feature and you suddenly realize there's a typo, you fix it and add it to the same commit you added your feature.

Later, the feature is canceled, you rollback that commit. You lost your fix. ⬇
⭐ Create an account.

When you are ready to save your repository online, you need to create an account, there are different websites (GitHub, GitLab, Bitbucket...). I prefer GitHub.

After creating your account, you need to go to "Add new repository" and give it a name. ⬇
⭐ Push your repository.

You will see something like this. We are only interested in the last three lines.

git branch -M main
git remote add origin https://github...
git push -u origin main

This will connect your local repository to your remote repository and push your commits
With this, you will have a history of your changes and your code online for potential employers to see.

In a future thread, I will explain branches, how to rollback, how to squash changes, and more! Tell me if you are interested.

I hope you learned something from this thread.⚡
You can follow @nachoiacovino.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.