Skip to content

Instantly share code, notes, and snippets.

@cwgem
Created April 5, 2018 15:29
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 cwgem/dbbe740a3dc769c2b00d3715683d39a3 to your computer and use it in GitHub Desktop.
Save cwgem/dbbe740a3dc769c2b00d3715683d39a3 to your computer and use it in GitHub Desktop.
Fixing up a post git push miss on a non-master branch
  1. git checkout master
  2. git pull --rebase to ensure master is up to date
  3. git checkout [branch here]
  4. Fix the issue with your branch
  5. git add and git commit -m "fix" to commit the fix change
  6. git rebase -i master (if this fails you need to figure out what is conflicting with master and fix it)
  7. Find the "fix" commit and change pick to f (This will essentially merge your fix with the previous commit and pretend like the commit never happened separately)
  8. Write your commit info out with editor of choice
  9. Since you've re-written history you'll need to force push the branch. Use git push --force-with-lease origin [branch here]. This will ensure that if someone else has made changes to the branch you won't clear out their changes and bail out safely
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment