Skip to content

Instantly share code, notes, and snippets.

@stouset
Created May 18, 2010 17:13
Show Gist options
  • Save stouset/405242 to your computer and use it in GitHub Desktop.
Save stouset/405242 to your computer and use it in GitHub Desktop.
#
# A set of aliases from my global .gitconfig taken from the most useful scripts in
# ddollar/git-utils and elsewhere on the 'net.
#
[alias]
# helper functions
current-branch = "!f() { B=$(git symbolic-ref HEAD) && echo ${B#refs/heads/}; }; f"
current-remote = "!f() { B=$(git config branch.$(git current-branch).remote) && echo ${B}; }; f"
current-merge = "!f() { B=$(git config branch.$(git current-branch).merge) && echo ${B#refs/heads/}; }; f"
current-track = "!f() { R=$(git current-remote) && M=$(git current-merge) && echo ${R}/${M}; }; f"
# end-user aliases
# * git remove - removes all deleted files from the index (you can pass
# filenames and directories to only remove stuff under
# those paths, as expected
# * git addremove - adds all untracked files and changes, and removes all
# deleted files from the index; accepts the same
# parameters as `git remove`
# * git wip - does an addremove, and commits a commit with the
# message "Work in progress", serves as a lightweight
# `git stash`; accepts the same parameters as `git
# remove`
# * git unwip - uncommits the latest commit and leaves the changes in
# your working tree
# * merge-feature - accepts a branch name, and merges that branch without
# fast-forwaring, forcing a merge commit to be made
# (useful to always keep a record of branch merges)
# * last - takes an integer parameter +n+, and shows a log for
# the last +n+ commits
remove = "!f() { git ls-files --deleted -z $@ | xargs -0 git rm -r; }; f"
addremove = "!f() { git add -v ${@-.}; git remove $@; }; f"
wip = "!f() { git addremove $@; git commit -m 'Work in progress'; }; f"
incoming = "!f() { T=$( [ \"${1}\" == \"\" ] && echo $(git current-track) || echo ${1} ) && git log ..${T}; }; f"
outgoing = "!f() { T=$( [ \"${1}\" == \"\" ] && echo $(git current-track) || echo ${1} ) && git log ${T}..; }; f"
unwip = reset HEAD^
merge-feature = merge --no-ff
last = log -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment