By now, we have learned that Git
is a Version Control System (VCS). But what does that really mean and how will it help us at Turing? While at Turing, and in our awesome careers after, Git or other VCS’s will be used. Git can help with so much. Some things include:
- Working on projects with multiple developers at the sometime.
- Allowing developers to revert and go back to an older version of the code.
- Ability to use branches to separate features of a program
See, its no so scary. Lets talk about the Git commands we need to learn:
- git init
- git add
- git status
- git commit
- git diff
In your terminal create a directory called learn_git
. Inside of there create a file called you_got_this.txt
. Now lets initialize git in the directory and add to repository.
cd learn_git
git init
We need too add our file and initialize commit. Committing is when content is added to the local repository. Before we do that it has to be in the staging area. The staging area is there to keep track of all the files which are to be committed. Any file which is not added to the staging area will not be committed. The staging area gives us control over which files need to be committed. We only initial commit once per project. After that enter whatever applicable information your are committing.
git add you_got_this.txt
git commit -m “Initial commit”
Use git status
to find out information regarding what files are modified and what files are the in the staging area. This command can be used whenever and without harm. Our file seems pretty boring. We’ll add some quotes, check the difference from the original with the "git diff" command, add our file and commit again.
echo “This is so much fun” >> you_got_this.txt
Echo “Almost done learning for now” >> you_got_this.txt
git diff
git add you_got_this.tx
git commit -m "Add quotes"
Now that we've commited the updated file we can check our status again to veryify we have nothing left to commit. We will get this following message.
On branch master
nothing to commitm working tree cleann
The diagram briefly talks about the steps we did above. For further instructions about what we covered, please refer to git-scm.com. All right, take a breath and soak it all in. Remember to practice, practice, practice!
😌 🍷