Git is a free and open source distributed version control system. There are several adoptions of the Git framework and one such popular application is GitHub. This cheat sheet features some of the most important and commonly used Git commands for easy reference.
Downloading Github
Setting-up user credentials
Code | Definition |
git config --global user.name “[firstname lastname]” | set a name that is identifiable for credit when review version history. |
git config --global user.email “[valid-email]” | set an email address that will be associated with each history marker. |
Setup and Initialization
Code | Definition |
git init | initialize an existing directory as a Git repository. |
git clone [url] | retrieve an entire repository from a hosted location via URL. |
Staging changes
Code | Definition |
git status | show modified files in working directory, staged for your next commit. |
git add [file] or git add . | add a file as it looks now to your next commit (stage). git add . adds all the files in repository. |
git commit -m “[descriptive message]” | commit your staged content as a new commit snapshot. |
Push and Pull changes from GIT
Code | Definition |
git push [branch] | Transmit local branch commits to the remote repository branch |
git pull | fetch and merge any commits from the tracking remote branch. |