Created
October 5, 2017 19:31
-
-
Save atheiman/ffe708d972c6d70bc75972f7730b3c76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gfixup() { | |
set -x | |
git add --all | |
git commit --fixup=$(git log --oneline | head -1 | cut -d ' ' -f 1) | |
git rebase --interactive HEAD~2 --autosquash | |
set +x | |
local branch_name=$(git symbolic-ref -q HEAD) | |
branch_name=${branch_name##refs/heads/} | |
branch_name=${branch_name:-HEAD} | |
echo 'Previous commit fixed up.' | |
echo 'To update a previously pushed branch, run:' | |
echo " git push origin $branch_name -f" | |
} | |
gitupdatefork() { | |
if [[ "$#" -ne 1 ]]; then | |
echo "Usage: ${FUNCNAME[0]} DEFAULT_BRANCH" | |
# exit current function | |
kill -INT $$ | |
fi | |
local DEFAULT_BRANCH="$1" | |
git checkout "$DEFAULT_BRANCH" | |
git fetch upstream "$DEFAULT_BRANCH" | |
git merge upstream/"$DEFAULT_BRANCH" | |
git push origin "$DEFAULT_BRANCH" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment