Git undo push


  • administrators

    You are on branch B, but actually you are supposed to be on branch A. You did a lot of updates, and pushed the change to the origina/branchB. How to fix this?

    1. git reset --soft HEAD~1 //undo the last commit
    2. git stash //save current changes
    3. git push -f origin branchB //reset remote branch
    4. switch to branchA
    5. git stash pop // recover current changes
    6. push