Online Mind Mapping and Brainstorming

Create your own awesome maps

Online Mind Mapping and Brainstorming

Even on the go

with our free apps for iPhone, iPad and Android

Get Started

Already have an account? Log In

Git by Mind Map: Git
5.0 stars - 1 reviews range from 0 to 5


A distributed version control system

Everything in Git is checksummed before it is stored

And referred to by that checksum.

SHA-1 hash is the mechanism used for checksumming

40 char string made of hex chars.

3 States

3 main states that files can reside


changed the file, but not committed


marked a modified file in it's current version to go into next commit snapshot


data is stored in the local database

3 Sections

3 main sections of any Git project

Working directory

single checkout of one version of the project

Staging area

A simple file

generally inside Git directory

Stores information about what will go into your next commit

Git directory

Git stores meta data and object database for the project


1. Modify files in working directory

2. Stage the files, adding snapshots of them to your staging area

3. Do a commit - which takes the files as they are in staging area and stores that snapshot permanently in Git directory

First time Git Setup

Git comes with a tool called 'git config'

lets you set configuration variables

The config vars are stored in 3 different places

/etc/gitconfig, contains values for every user on the system and their respos, to read/write from this file, use 'git config --system ....'

~/.gitconfig, specific to user, to read/write to this file, use 'git config --global ...'

.git/config, specific to single respository


git config --list

Getting help

git help <verb>

Setting up a Repository

Add a project to a Git repo

initializing a repo in existing folder, $git init, creates a.git directory, nothing is tracked yet (until the first commit), Adding files to git, $git add *.c, $git add README, $git commit -m 'initial project version'

Clone an existing Git repo(from other server)

$git clone git://, creates a directory /proj, Also checks out a working copy

2 stages


are files that were from last snapshot


Checking the Status of files

$git status

tracking new files

$git add FILENAME

staging changed files

Viewing staged and unstaged changes

$git status is too vague

use $git diff

To see whats changed but not staged, use $git diff

To see whats staged and going into commit, use $git diff --cached, or use (>1.6.1) $git diff --staged

Ignoring Files

files you don't want to add

or show as being untracked

.gitignore file

blank lines are ignored

lines with # are ignored

standard glob patterns work

patterns ending with / indicate folder

! - to negate a pattern

Committing your changes

$git commit

Skipping staging area

$git commit -a

Removing files

$git rm FILENAME, removes it from Stage and working copy

$rm FILENAME, removes it in working dirctory, needs to be staged and committed

a scenario, If you make changes to a file and don't stage and want to delete, use $git rm FILENAME -f

Removing it only from stage, $git rm --cached FILENAME

Moving files

Git doesn't track file movement

If you rename a file, no meta data is stored in Git to capture that

command, $git mv file_from file_to

Viewing commit history

$git log

Undoing things

changing your last commit

$git commit --amend

takes staging area and used for commit

snapshot will look exactly the same

unstaging a staged file

$git reset HEAD filename

Unmodifying a modified file

$git checkout -- filename

be careful - you modified working copy changes would be lost

Remote repositories

checking the remote for existing repo

$git remote -v

adding remote repos

$git remote add [shortname] [url of repo]

This gives a right to fetch the git repo into local repo

Ex: $git remote add pb git://, $git fetch pb

Fetching and Pulling from remotes

$git fetch [remote-name]

fetch only pulls data to local repo - doesn't merge with working directory

$git pull, pull fetches the data and merges with working copy/branch

Pushing to remotes

$git push [remote-name] [branch-name]

Inspecting remotes

$git remote show [remote-name]

Removing and renaming remotes

$git remote renamte [old] [new]

$git remote rm [remote-name]


Listing your tags

$git tag

$git tag -l v1.4.2 (searches)

Creating Tags

2 types of tags, lightweight, like a branch that doesn't change, a pointer to a specific commit, annotated, stored as full objects in Git database, check-summed, contains tagger name, email, date, have a tagging message, can be signed with GPG, creating, $git tag -a v1.4 -m 'my version 1.4'

$git show [tag-name]