Last updated: June 26, 2017

This note can be used as a cheat sheet. Below is a brief description of most often used git commands.

  1. Basics
  2. Index operations
  3. Version operations
  4. Operations on the branch
  5. Remote repository


  • Working directory
    • Working directory | working tree Catalog in which we make changes. It contains check out latest version in a current branch: current version, HEAD, and changes that we made
  • Index
    • Staging area Contains changes which will be committed to a new version in the local repository. Changes from working catalog can be added to index by git add.
  • Local repository
    • A local copy of a repository. All operations are being done on a local repository. If we want to the public about changes we should push it out to a remote repository using git push.
  • Version
    • File version saved in repository | Commit We can connect versions by git merge. A version may have more than one parent. Git checkout is used to change files in a working directory to files of a given version.
  • Branch
    • Linearly ordered set of vertices in graph version. Usually, there is a current branch whose pointer is moved together with the HEAD when executing git commit, git reset …
  • Remote Branch
    • Branch in the remote repository.
  • Tracking branch
    • Branch in local repository that tracks branch.
  • HEAD
    • Indicates the current version from the local repository.
    • The previous HEAD value, before any of the HEAD changing operations:
      • git commit
      • git merge
      • git pull
      • git checkout
      • git reset, etc.
  • Master
    • Main branch. After creating new repository this is the current branch.  The way we work with GITs is that for every major task we create a new branch, we work in that branch, and then, as we already have the functionality, we merged this branch into a master.

Index operations:

Changes to the working directory will not be self-referenced to the new version in the local repository when we do git commit. Only changes recorded in the index are commenced. Below are few basic commands and probably all commands that we need for work with git:

  • git add .
    • Adds changes to all files in the working directory I subcategory. Files that were not previously included in the current version are added.
  • git status
    • Displays information about which changes to the working directory have been stored in the index and which are not.
  • git rm file
    • Deletes files from working directory and index
  • git mv file1 file2
    • Renames the file file1 to a file and saves the change in the index.
  • git reset file
    • Reverse operation to git add. Sets the file in the index to its current version, which in effect removes changes to the file added to the index by git add.

Version operations:

  • git commit -m “description”
    • Creates a new version in the local repository. This version will differ from the current changes in the index. After executing this command, the newly created version becomes current, HEAD, and the current branch point to a new version and the index is identical to the current version (no changes).
  • git commit –amend -m “description”
    • This is the most common form of the commit. The option causes the indexes to be added to the index in all files in the working directory that existed in the current version before they were uploaded.
  • git log
    • Shows the version history to the current version, ie the vertices of the version graphs that are available from the current version, always going to the father. This command has a number of additional options that let you specify exactly which versions we want to watch.
  • git diff
    • Displays the differences between the index and the working directory.

Operations on the branch:

  • git branch
    • Display branches in the local repository.
  • git branch -d name
    • Deletes branch Name, deletes the Name pointer itself, and not the version to which this branch points. This version may still be available from other branches.
  • git checkout name
    • Changes the current branch to name if Name is the branch name. HEAD is also set to the version indicated by name. git merge name1, name2, name3 Creates a new version by including the versions pointed to by branches name1, name2, and name3 to the current version. Usually, we want to merge only one branch, but you can and several at a time.

Remote repository:

  • git remote
    • Displays the list of remote repositories.
  • git push
    • Writes to remote branches in the default remote repository (usually the origin) changes from a branch tracking them in a local repository.
  • git pull
    • Takes changes from the appropriate remote branch to the branch that tracks the remote branches. Trying to automatically merge changes.
  • git fetch
    • It works like a git pull with the difference that it does not automatically erase changes to local branches.


  1. ANSI/IEEE 1471-2000 Recommended Practice for Architectural Description for Software-Intensive Systems
  2. ISO/IEC/IEEE 42010:2011, Systems and software engineering — Architecture description
  3. What does a web application architecture include
  4. Architectural Styles and the Design of Network-based Software Architectures

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee