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? Let's learn th...
⭐ 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 Image
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.⚡

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Drew Pyke ⚡

Drew Pyke ⚡ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!