Let's talk about Git.![Hochspannungszeichen ⚡](https://abs.twimg.com/emoji/v2/72x72/26a1.png)
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.![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
#100DaysOfCode #git #github #javascript #CodeNewbie #js
![Hochspannungszeichen ⚡](https://abs.twimg.com/emoji/v2/72x72/26a1.png)
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.
![Thread 🧵](https://abs.twimg.com/emoji/v2/72x72/1f9f5.png)
#100DaysOfCode #git #github #javascript #CodeNewbie #js
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
![Pfeil nach unten ⬇](https://abs.twimg.com/emoji/v2/72x72/2b07.png)
![Mittelgroßer Stern ⭐](https://abs.twimg.com/emoji/v2/72x72/2b50.png)
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.
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.
![Hochspannungszeichen ⚡](https://abs.twimg.com/emoji/v2/72x72/26a1.png)