Version Control with Git: Git Cheatsheets for Quick Reference

Key Points

Automated Version Control
  • Version control is like an unlimited ‘undo’.

  • Version control also allows many people to work in parallel.

Setting Up Git
  • Use git config to configure a user name, email address, editor, and other preferences once per machine.

Creating a Repository and Tracking Changes
  • git init initializes a repository.

  • git status shows the status of a repository.

  • Files can be stored in a project’s working directory (which users see), the staging area (where the next commit is being built up) and the local repository (where commits are permanently recorded).

  • git add puts files in the staging area.

  • git commit saves the staged content as a new commit in the local repository.

  • Always write a log message when committing changes.

Exploring History
  • git diff displays differences between commits.

  • git checkout recovers old versions of files.

Ignoring Things
  • The .gitignore file tells Git what files to ignore.

Working with Branches
  • git branch to view current branches

  • git branch branch-name to create a new branch

  • git checkout branch-name to switch to a branch

  • git branch -m branch-name to rename a branch

  • git merge branch-name to merge a branch

  • git branch -d delete-me to delete a branch

  • Checking out a branch changes the “active” files in your repository directory.

  • Merging applies commits from one branch to another.

  • Merge commits are used to glue two histories together.

  • A local Git repository can be connected to one or more remote repositories.

  • Use the HTTPS protocol to connect to remote repositories until you have learned how to set up SSH.

  • git push copies changes from a local repository to a remote repository.

  • git pull copies changes from a remote repository to a local repository.

  • git clone copies a remote repository to create a local repository with a remote called origin automatically set up.

Graphical User Interface (GUIs)
  • There are a number of GUI applications available for working with Git.

  • Conflicts occur when two or more people change the same file(s) at the same time.

  • The version control system does not allow people to overwrite each other’s changes blindly, but highlights conflicts so that they can be resolved.

Git Cheatsheets for Quick Reference

Both resources are also available in other languages e.g. Spanish, French, and more.

In-Depth Documentation/Training


A group of changes to one or more files that are or will be added to a single commit in a version control repository.
To record the current state of a set of files (a changeset) in a version control repository. As a noun, the result of committing, i.e. a recorded changeset in a repository. If a commit contains changes to multiple files, all of the changes are recorded together.
A change made by one user of a version control system that is incompatible with changes made by other users. Helping users resolve conflicts is one of version control’s major tasks.
The Hypertext Transfer Protocol used for sharing web pages and other data on the World Wide Web.
(a repository): To reconcile two sets of changes to a repository.
A set of rules that define how one computer communicates with another. Common protocols on the Internet include HTTP and SSH.
(of a repository) A version control repository connected to another, in such way that both can be kept in sync exchanging commits.
A storage area where a version control system stores the full history of commits of a project and information about who changed what, when.
To eliminate the conflicts between two or more incompatible changes to a file or set of files being managed by a version control system.
A synonym for commit.
SHA-1 hashes is what Git uses to compute identifiers, including for commits. To compute these, Git uses not only the actual change of a commit, but also its metadata (such as date, author, message), including the identifiers of all commits of preceding changes. This makes Git commit IDs virtually unique. I.e., the likelihood that two commits made independently, even of the same change, receive the same ID is exceedingly small.
The Secure Shell protocol used for secure communication between computers.
A record of when a particular event occurred.
version control
A tool for managing changes to a set of files. Each set of changes creates a new commit of the files; the version control system allows users to recover old commits reliably, and helps manage conflicting changes made by different users.