Skip to content

Instantly share code, notes, and snippets.

@ObiWahn ObiWahn/.gitconfig
Created Jul 6, 2017

Embed
What would you like to do?
some aliases for your .gitconfig
[alias]
#https://github.com/seveas/git-spindle
##basic
treeall = "log --graph --pretty=oneline --decorate --abbrev-commit --all"
tree = "log --graph --pretty=oneline --decorate --abbrev-commit"
treelong = "log --graph --pretty='%C(yellow)%h %d %Cblue%ad %Cgreen%an %Creset%s ' --date=relative"
logall = "log --all --date-order"
stat = "diff --stat HEAD"
cat = "cat-file -p"
## basic funcitons
#show the last n people who commited on file
show-last = "!_git_fun() { git log \"$1\" |grep Author |awk ' !x[$0]++' |head -\"$2\"}; _git_fun"
#rest merge for single file
reset-merge-of-file = "!_git_fun() { if [ -f \"$1\" ]; then git merge-file -L HEAD -L BASE -L OTHER -p $(git unpack-file :2:\"$1\") $(git unpack-file :1:\"$1\") $(git unpack-file :3:\"$1\"); rm .merge_file_*; else echo 'you need to provide a file'; fi; }; _git_fun"
#github
githup-init = "!_git_fun() { \
test -z \"$1\" && { echo 'usage: git github-init repo'; exit 1; }; \
git remote add origin \"git@github.com:<your_user>/$1.git\"; \
git push -u origin master; \
}; _git_fun"
githup-init-user-repo = "!_git_fun() { \
test -z \"$1\" -o -z \"$2\" && { echo 'usage: git github-init-user-repo user repo'; exit 1; }; \
git remote add origin \"git@github.com:$1/$2.git\"; \
git push -u origin master; \
}; _git_fun"
githup-add-upstream-user-repo = "!_git_fun() { \
test -z \"$1\" -o -z \"$2\" && { echo 'usage: git github-add-upstream-user-repo user repo'; exit 1; }; \
git remote add upstream \"git@github.com:$1/$2.git\"; \
}; _git_fun"
## function example
test = "!gitfun() { echo \"$1\n$2\"; }; gitfun"
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.