Skip to content

Instantly share code, notes, and snippets.

@AshConnolly
Last active August 8, 2020 10:33
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 AshConnolly/b5ddca1aab1161750d5f96a46f30a936 to your computer and use it in GitHub Desktop.
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! πŸ˜ƒ
# 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