Skip to content

Instantly share code, notes, and snippets.

@Anmo
Last active January 4, 2016 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anmo/4151f02977ef1a9ca0fa to your computer and use it in GitHub Desktop.
Save Anmo/4151f02977ef1a9ca0fa to your computer and use it in GitHub Desktop.
[alias]
co = checkout
cob = checkout -b
ll = branch
cm = !git add -A && git commit -m
theirs = checkout --theirs
ours = checkout --ours
for-p2c = "!f() { cmd=\"$1\"; msg=\"${2-continue}\"; eval $cmd; git submodule foreach --recursive \"eval $cmd || echo $msg\"; }; f"
for-c2p = "!f() { cmd=\"$1\"; msg=\"${2-continue}\"; git submodule foreach \"git for-c2p \\\"$cmd\\\" \\\\\"$msg\\\\\" || echo $msg\"; eval $cmd; }; f"
clone-branch = "!f() { path=${3-$2}; branch=${4-master}; git clone --recursive -b $branch $1$2.git $path; cd $path; git change-branch $branch; }; f"
fetch-sub = "!f() { git for-p2c \"git fetch --all\"; }; f"
change-branch = "!f() { branch=${1-master}; git fetch-sub; git for-p2c \"git co $branch\"; }; f"
create-branch = "!f() { branch=$1; from=${2-master}; remote=${3-origin}; git for-p2c \"git cob $branch $from\"; git push-branch $branch $remote; }; f"
commit-branch = "!f() { msg=\"${1-sorry colleges, I forget to write a comment}\"; git for-c2p \"git cm \\\"$msg\\\"\" \"nothing to commit\"; }; f"
push-branch = "!f() { branch=${1-master}; remote=${2-origin}; git for-p2c \"git push -u $remote $branch:$branch\"; }; f"
commit-push = "!f() { branch=$1; msg=\"${2-sorry colleges, I forget to write a comment}\"; remote=${3-origin}; git commit-branch \"$msg\"; git push-branch $branch $remote; }; f"
pull-branch = "!f() { branch=${1-master}; remote=${2-origin} prune=${3+--prune} rebase=${4+--rebase}; git for-p2c \"git pull $remote $branch $prune $rebase\"; }; f"
merge-branch = "!f() { branch=${1-master}; git for-p2c \"git merge $branch\"; }; f"
pull-merge = "!f() { to=$1; from=${2-master}; remote=${3-origin}; git change-branch $from; git pull-branch $from $remote; git change-branch $to; git merge-branch $from; }; f"
status-sub = "!f() { git for-p2c \"git status\"; }; f"
stash-sub = "!f() { git for-c2p \"git stash\" \"nothing to stash\"; }; f"
stash-pop-sub = "!f() { git for-p2c \"git stash pop\" }; f"
del-locally = "!f() { branch=$1; git for-p2c \"git branch -D $branch\"; }; f"
del-remote = "!f() { branch=$1; remote=${2-origin}; git for-p2c \"git push $remote --delete $branch\"; }; f"
del-branch = "!f() { branch=$1; remote=${2-origin}; git del-locally $branch; git del-remote $branch $remote; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment