Last active
August 8, 2020 10:33
-
-
Save AshConnolly/b5ddca1aab1161750d5f96a46f30a936 to your computer and use it in GitHub Desktop.
Updated my #git amend & push force! Add them to your "~/.bash_profile" & use with care! π
This file contains 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
# git add commit amend // usage: "gaca" | |
function gaca() { | |
# Add all files & changes to your most recent local commit | |
git add . | |
git commit --amend --no-edit | |
} | |
# To push this amended change into your most recent * remote * commit use the next function (after using gaca) π¨ WITH EXTREME CAUTION! π¨ If you git push force to wrong remote branch you will overwrite its entire branch history with a different branch! If possible always choose to add another commit instead! | |
# git push --force-with-lease // usage: "gpf branch-name" | |
# typing the branch name is a sanity check! π | |
function gpf() { | |
# --force-with-lease ensures you do not overwrite the commits of others that have been pushed to the remote branch since your last commit! | |
git push origin "$1" --force-with-lease | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment