Skip to content

Instantly share code, notes, and snippets.

@trishalanglois
Last active July 7, 2019 21:26
Show Gist options
  • Save trishalanglois/27b4780695928de9b5fafe67bc8f30a9 to your computer and use it in GitHub Desktop.
Save trishalanglois/27b4780695928de9b5fafe67bc8f30a9 to your computer and use it in GitHub Desktop.

The Beginner's Guide to Git

So, you're just starting out in the terminal and getting to know git? This is the perfect place for you. Check out this handy list of shortcuts to get you zooming around your Terminal in no time! Eat your heart out, Sonic.

Sonic the hedgehog

Action Commands

  • git init - initializes git to start tracking what you're doing. You're not tracking any changes yet, but you have the ability to do so.
  • git add - adds your file to the staging area. This means that your file is ready to be saved, but you haven't actually saved it yet. This is a crucial step before you commit or save your progress.
    git add file_name.extension
    

So, for example, you could type git add mod0_homework.txt, and it would be in the staging area.

  • git commit - you're finally saving a "snapshot" of you project! This will save this particular version of your file.
    git commit -m 'Commit comment'
    

So, for example, you could type git commit -m Initial commit and the mod0_homework.txt that we had put into staging is now committed, meaning that it was saved at that moment. We can repeat this process as many times as we want as we're making changes to our documents and projects.

Safe/Informative Commands

  • git status - updates you on the status of your current repository and how they're being tracked. This is especially handy when you're adding and committing files.
  • git diff - this is a fun command to show you the modifications that have happened since your last commit.

Why do we use Git?

  1. If we make a mistake or want to change something, we can time travel back to a previous commit and work from there. Great Scott!
  2. We can branch different parts of our project to trial different ideas.
  3. Git helps us work together on the same project at the same time. Teamwork makes the dream work.
  4. We can see who made what changes on the project making sure we're giving kudos to all the right people.

Additional Resources

Feel like you can't get enough of git? Check out the following resources for more information!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment