Git is a powerful system for distributed version control.

To get documentation for a Git command:

$ man git-[command-name]

$ git help [command-name]

Configuring Git for all local repositories

$ git config --global "[name]"

To set the name to commit transactions

$ git config --global "[email address]"

To set the email to commit transactions


Branches - an important part of working with Git.

$ git status

To check the status of the repository

$ git branch [branch-name]

Creates a new branch

$ git checkout [branch-name]

Switches to the specified branch and updates the working directory

$ git merge [branch]

Combines the specified branch’s history into the current branch.

$ git branch -d [branch-name]

Deletes the specified branch

Make changes

$ git log

Lists version history for the current branch

git log --pretty=oneline

Lists version history for the current branch in one line format

$ git diff [first-branch]...[second-branch]

Shows content differences between two branches

$ git show [commit]

Outputs metadata and content changes of the specified commit

$ git add [file]

Snapshots the file in preparation for versioning and stages the changes

$ git commit -m "[descriptive message]"

Records file snapshots in version history

Redo commits

$ git reset [commit]

Undoes all commits after [commit] and preserve changes locally

$ git reset --hard [commit]

Discards all history and changes back to the specified commit

Create repositories

$ git init

To start out a new repository (initial setup)

$ git remote add origin [url]

To link the local repository to an empty GitHub repository

$ git clone [url]

Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits

$ git fetch origin

To fetch a commit using its hash

The .gitignore file

To exclude files from being tracked with Git. It is done in a special file - .gitignore.

Setting up .gitignore

Create a file in project directory named .gitignore (Note: the name starts with a period).

Synchronize changes

$ git fetch

Downloads all history from the remote tracking branches

$ git merge

Combines remote tracking branches into current local branch

$ git push

Uploads all local branch commits to GitHub

$ git pull

Updates your current local working branch with all new commits from the corresponding remote branch on GitHub. git pull is a combination of git fetch and git merge

GitHub and Bitbucket

GitHub ( and Bitbucket ( – hosting services for software development and version control using Git.

Git tutorials, resources and commands