Important Git Commands

A commented list of important git commands and concepts

# Create an empty repository for this directory
git init
# Create an bare repository 
# Mainly used as a central repository for synchronization
git init -bare

# Remove deleted, add new and modified filed
# to the so called index, which can be committed afterwards
git add -A

# Adds the changes noted in the created index
# into the repository with the comment 
git commit -m "commitmessage"

# Add alias origin to the repo at q:/git/SW2
git remote add origin q:/git/SW2

# Transfer local commits of the repository with alias origin
git push origin master
# Transfer central commits of the repository with alias origin
# to the local repo
git pull origin master
# Remove tracked file from index
git rm --cache full_filename

Principles of Operation

Several program functions (init, add, rm …) are accessed by the git command. The .git directory is the datastore.

Files within a directory with .git directory can be either tracked or untracked. New files or files matching rules stated in the .gitignore file are untracked. Before a file or a modification of a file can be committed it has to be added to the index. This state is also named staged.