Dienstag, 4. Februar 2014

Must Have Git Aliases

Git Shortcut

This is first thing you should do. Aliasing git as `g` will save you a lot of typing. After this symlink creation you can access git with only typing `g` in the command line.
$ sudo ln -s `which git` /usr/bin/g
I'm using git now for some years and over the time I came up with a long list of git aliases. Git is great and can give you a great coding experience with it's customizable shortcuts.

Your .gitconfig file is located in your home dir. All examples can be added to the [alias] section in this file.
$ nano ~/.gitconfig

Basic Aliases

  co = checkout
  cp = cherry-pick
  p  = pull
  squash = merge --squash
  st = status
  df = diff
  b = branch

Advanced Usage

Revert a file

  rv = checkout --

Merging

  ours = checkout --ours --
  theirs = checkout --theirs --

Stashing

  sl = stash list
  sa = stash apply
  ss = stash save

Danger! Cleanup working dir

This alias will reset all modified files!
cleanup = !git reset --hard && git clean -f 

List all aliases

alias = config --get-regexp 'alias.*'

Log One Line

logol = log --pretty=format:"%h\\ %s\\ [%cn]"

Search in files

search = "grep -Iin"

Vagrant

vup = !vagrant up
vsu = !vagrant suspend
vss = !vagrant ssh
vde = !vagrant destroy
vpr = !vagrant provision

Keine Kommentare:

Kommentar veröffentlichen