Introduction

These are my personal notes on using Git.

Since I use Git for tracking the content of all of my source code projects, I use this as a quick overview on how to use Git for daily tasks.

I recommend to take look at the official Git documentation if you are new to Git or want to know more detailed information.

Note: This document is a work in progress.

Commands

Help

To get help about a Git command run:

git $command --help

Example:

git init --help

To get a list of the most commonly used Git commands run:

git --help

Create

Create new Repository:

mkdir ~/new_repo
cd ~/new_repo/
git init

Add single file to ~/new_repo/:

cd ~/new_repo/
touch README
git add README

Add all existing files to ~/new_repo/:

cd ~/new_repo/
git add *

Clone

Clone existing Repository from local files:

git clone ~/existing_repo/ ~/new_repo/

Clone existing Repository using the git protocol:

git clone git://git.hanez.org/git_repo.git

Clone existing Repository using the HTTP/HTTPS protocol:

git clone https://git.hanez.org/git_repo.git

Clone existing Repository using SSH:

git clone ssh://git@git.hanez.org/git_repo.git

Show

Todo

Revert

Go back to HEAD and restore all files deleted with 'git rm' since last commit.:

git checkout HEAD -- .

rm

Remove a file from the repo without deleting it from disc.

git rm --cached file

Update

Todo

Patches

Todo

Publish

Commit all local changes with message:

git commit -a -m "Commit Message"

Push local changes to origin:

git push

Submodules

Init and update all submodules of a repository

git submodule update --init --recursive

Configuration

The global Git configuration file is found in $HOME/.gitconfig

Get help about the configuration:

git config --help

Links

Here you will find more information about Git: