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.
- 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.
- 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.
- 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!
- We can branch different parts of our project to trial different ideas.
- Git helps us work together on the same project at the same time. Teamwork makes the dream work.
- We can see who made what changes on the project making sure we're giving kudos to all the right people.
Feel like you can't get enough of git? Check out the following resources for more information!