Skip to content

Instantly share code, notes, and snippets.

@sdesalas
Last active March 10, 2023 15:31
Show Gist options
  • Save sdesalas/78c829d758710d0bbe7095a887fd0c3d to your computer and use it in GitHub Desktop.
Save sdesalas/78c829d758710d0bbe7095a887fd0c3d to your computer and use it in GitHub Desktop.
Git like a pro
# Remove commit from current branch. Remote branch is MINE: I dont care about other people's commits (bad).
git rebase --onto $COMMIT_HASH^ $COMMIT_HASH && git push --force
# Remove commit from current branch. Remote branch is SHARED: Be careful with other people's commits.
git rebase --onto $COMMIT_HASH^ $COMMIT_HASH && git push --force-with-lease
# Alternate to rebasing
git reset --soft $COMMIT_HASH_BEFORE_CHANGES or HEAD~$NO_COMMITS_BEHIND
git stash
git checkout uat
git pull
git stash pop
git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment