To make the most of Git you’ll want to make some changes to files and submit them for safe keeping. At the root of BookContents is a README.md or markdown file. This is basically a text file with some clever formatting. Open this with Visual Studio and add in some information.
In the first line I’ve added the above two lines. Make sure you’re more original than I am with your welcome message. Once you’re done with your welcome message open Git Bash. Enter the following command:
git status
The status command asks Git to show you what’s changed. The changes shown reflect any file modified throughout all the content in the BookContent repo. The line “Changes not staged for commit” show you which files have been modified, added, or deleted.
In the changes you’ll see modified : README.md as well as instruction to discard changes if you would like to reset the file. To keep the changes, enter the command:
git add README.md
This adds the README.md to a list of files that will be included with a checkpoint of changes. In git terms this “stages” the file for commit. Think of this as a save point in a game. You can load your game from a checkpoint and start over if you mess up. Git grants your code with the same ability. To save the checkpoint we need to commit the changes with the following command:
git commit -m “adding changes to readme”
The git commit command has two parts: the -m which indicates we’ll add a note to our save point and the “Adding changes to README.md,” which is the message to identify what the commit was created for.
This turns into a save point which we can come back to. You’ll also notice the section that says [ master 58a4fb7]; this is the code name for the save point. This is how Git remembers everything you’ve added to the repo. These numbers and letters are called hash codes. Your commit will have a different hash, so don’t worry if it looks different. Every commit will be unique.
GitHub comes into play once you want to save your changes on your GitHub account. To upload the commit, use the command:
git push
Depending on how you’ve set your security settings you may need to enter a user name and password. Once that’s done your commit will be pushed into GitHub. This means that even if your computer gets eaten by zombies, your work is safe on GitHub.
The pattern that we repeat is Add Commit Push. Every time you want to create a save point for your work, remember “Add, Commit, Push” to create a checkpoint.
To inspect your work, go to your GitHub page in a web browser.
The changes you’ve made to your README.md will appear in your fork of the repo.