Git

Configuration

Type Option Config
System glogal --system /etc/gitconfig
User global --global ~/.gitconfig
Repository local $REPO/.git/config

Basic user wide configuration

git config user.name "King Kuban"
git config user.email "king_kuban@myterritory.net"
git config --global alias.glog "log --graph --oneline"
#git config --global color.ui true # It is  default from some version.

Branches

List branches

git branch -a

Switch to another branch

git checkout <name>

Create branch

git branch <name>
git checkout <name>

or

git checkout -b <name>

Merge changes from different branch

git merge <name>

Rename local branch

git branch -m <old-name> <new-name>

Delete old branch on remote

git push origin --delete <old-name>

Push new branch to remote and track it

git push origin -u <new-name>

Sync with remote after branch delete

git fetch --all --prune

Mercurial conversion

Git server

Only we need is bare repository.

It is a convention bare repositories have suffix .git

Repository

Create repository

git init --bare repo.git

Or clone existing one.

git clone --bare repo repo.git

Videos