Skip to content

Instantly share code, notes, and snippets.

@npatmaja npatmaja/git-aliases.md
Last active Aug 29, 2015

Embed
What would you like to do?
Gist aliases in `~/.gitconfig`
[alias]
	bl = branch -l
	co = checkout
	ec = config --global -e
	up = !git pull --rebase --prune $@ && git submodule update --init --recursive
	pushm = push origin master
	pullm = pull origin master
	pusho = !git push origin "$(git rev-parse --abbrev-ref HEAD)"
	pullo = !git pull origin "$(git rev-parse --abbrev-ref HEAD)"
	cob = checkout -b
	cm = !git add -A && git commit
	save = !git add -A && git commit -m 'SAVEPOINT' # adds all changes including untracked files and creates a commit
	wip = !git add -u && git commit -m "WIP"		# commits tracked changes and creates a commit
	undo = reset HEAD~1 --mixed						# resets the previous commit, but keeps all the changes from that commit in the working directory
	amend = commit -a --amend						# modify the previous commit
	wipe = !git add -A && git commit -qm 'WIPE SAVEPOINT' && git reset HEAD~1 --hard	# commits everything in my working directory and then does a hard reset to remove that commit. However, the commit is still there, but it's just unreachable
	bclean = "!f() { git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs git branch -d;  }; f"
	bdone = "!f() { git checkout ${1-master} && git up && git bclean ${1-master};  }; f"
	st = status
	ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
	ll  = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
	lg = log --all --decorate --graph --oneline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.