GIT, distributed version control system

  1. Git init
  2. Alias
  3. Compare Branches
  4. HTTP fetch access
  5. Clone, Fetch and Pull via HTTP; PUSH via SSH

Git init

Configuration file exmaple can be found: .gitconfig

Path on Windows

  • C:/Users/<UserName>/.gitconfig

Path on Linux

  • /home/<UserName>/.gitconfig

Default configuration for all repo


$ git config --global user.name "User"
$ git config --global user.email "user@mail.com"
$ git config --global color.diff auto
$ git config --global color.status auto
$ git config --global color.branch auto
$ git config --global core.editor "nano"
                

To overwrite config for a single repo use the same command without '--global'

Alias

  • a = add
  • c = commit
  • ca = commit --amend
  • b = branch
  • s = status
  • l = log --decorate --date=relative
  • ll = log --decorate --oneline --date=relative
  • lg = log --graph --decorate --date=relative
  • lga = log --graph --decorate --date=relative --all
  • llg = log --graph --decorate --date=relative --oneline
  • llga = log --graph --decorate --date=relative --oneline --all
  • k = checkout
  • d = diff
  • ds = diff --stat
  • f = fetch
  • pl = pull
  • m = merge
  • r = cherry-pick
  • o = remote
  • ps = push
  • rhh = reset HEAD --hard
  • rhf = reset HEAD
  • lln = log --pretty=format:'%h - %an | %ar | %s'

Compare Branches


$ git log master ^bug_fix
                

HTTP fetch access


$ cd gitproject.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update
$ ./hooks/post-update
                

Clone, Fetch and Pull via HTTP; PUSH via SSH


$ git clone http://www.homepage.lt/web-share/repo.git                
$ git remote set-url --push origin ssh://user@www.homepage.lt:22/path/to/repo.git
$ git remote -v
origin  http://www.homepage.lt/web-share/repo.git (fetch)
origin  ssh://user@www.homepage.lt:22/path/to/repo.git (push)
                

Commit part of the file

http://nuclearsquid.com/writings/git-add/