I first began using Git because Github was where all the cool kids hung out. They posted all their cool code and snippets and projects online and had dozens of followers. Yet the only people who could see my super awesome projects that printed “Hello World” were me and the Chrome incognito man.
So I looked into Github a bit more and realized that Github is actually a resource for users of Git, an easy-to-learn-and-use SCM tool (software configuration management–basically, Dropbox for your software) that works from your command line (though there are also GUIs available, we’re pretty cool cats and prefer the command line–it’s simple and unambiguous).
A brief overview of terms that we’ll be going over in more detail unless I forget (Git commands will appear in
text like this):
- repository – This is what we call the structure that Git uses to store your project and the changes you make to it. Do not confuse this with the folder that your project is in. A Git repository is the
.gitsubdirectory in your project folder, which keeps references to your changes (or
add– Git won’t automatically infringe on your privacy and steal all your code. You have to give up your files yourself. So to allow Git (your
.gitrepository) to track your files, you can run
git add file1 file2 file3(only track
file1, file2, file3),
git add .(add all changes in the current directory),
git add --all(add all changes in this directory and all subdirectories), etc.
commit– just like every commitment you make in life, these stick around. Every time you “commit” a set of changes to your files, those changes will stay in your history forever. That sounds scary, but it’s actually pretty great because you can go back to that moment in time at any time. (Or, like the social commitments you make as an EECS major, they can also be ignored forever.)
revert– Basically, scrape out a bad commit. Pass this command a commit ID and it’ll remove it from your codebase.
status– See all changes you’ve made that haven’t been committed or files you’ve changed that you haven’t added to your repository.
log– See recent commits.
clone– Make a copy of the specified remote repository on your machine.
push– Push your local commits to the remote repository.
pull– Sync up your local repository with the remote repository, pulling in all commits that have been made since the last time you’ve synced. You should always pull before you push.