merge-pr = "!f() { git fetch $1 $2; git branch _FETCH_HEAD FETCH_HEAD && git rebase HEAD _FETCH_HEAD && git checkout master && git merge --ff-only _FETCH_HEAD; git branch -d _FETCH_HEAD; }; f"
Note: This merges only to master, no way to specify another merge target. Feel free to suggest improvements.
pr = "!f() { git checkout develop && git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1 && git rebase -i origin/develop && git checkout develop && git merge - && git push; }; f" prm = "!f() { git checkout master && git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1 && git rebase -i origin/master && git checkout master && git merge - && git push; }; f"
sync = "!f() { echo \"$(tput setaf 4)Syncing this branch with origin master$(tput sgr 0)\" && git fetch origin master && git rebase origin/master && echo \"$(tput setaf 2)Branch sync successful$(tput sgr 0)\"; }; f" ship = "!f() { echo \"$(tput setaf 4)Shipping this branch to master$(tput sgr 0)\" && git checkout master && (git merge --ff-only - || (echo \"$(tput setaf 1)Could not merge branch into local master\\nRun git sync before running this command\\nIf this error persists, you have local, un-pushed commits in your master branch\\nPush them to origin master or move them into a branch before running this command$(tput sgr 0)\"; git checkout -; return 1)) && (git push origin master || (echo \"$(tput setaf 1)Could not push branch\\nRun git sync before running this command$(tput sgr 0)\"; git reset --hard HEAD@{1}; git checkout -; return 1)) && echo \"$(tput setaf 2)Branch ship successful$(tput sgr 0)\"; }; f"
git push --force-with-lease origin HEAD:<remote-branch-name>
Note: This merges only to master, no way to specify another merge target. Feel free to suggest improvements.