Git glossary

Git actions and commands

Action Description Command line
Initialize Initialize a Git repository git init
Status Check the status of changes git status
Add Add files to the stage git add filename
Commit A named saved state for added files git commit -m "message"
Diff Differences in a file between commits git diff
Log History of commits git log
Branch Named set of commits git branch
Push Send commits to GitHub git push
Pull Download commits from GitHub git pull

FAQ

  • How often should you commit?
    • A commit should complete a single problem or accomplishment. How large is a single problem? It depends. It might be a single line of code. It might be writing a full document.
    • The commit message should focus on why the changes were made because the exact nature of the changes can be shown with inspecting the commit.
  • How often should you push?
    • Less often than you commit. It is easier to alter things or deal with any problems associated with Git when the changes are local than after you have pushed to GitHub.
    • Once you have a coherent chunk of commits is a good time to push. Pushing also serves as a backup of your project.
    • Pushing makes your work public, so it is a good idea to have some level of completeness or have code that works.