Skip to content

Instantly share code, notes, and snippets.

@ramingar
Created April 29, 2022 09:17
Show Gist options
  • Save ramingar/0fb4033fdcb88662759f41257d5562ee to your computer and use it in GitHub Desktop.
Save ramingar/0fb4033fdcb88662759f41257d5562ee to your computer and use it in GitHub Desktop.
Revert your repo to an older commit and preserve all intervening work #git #revert #preserve #master

Esto nos sirve para poder pushear un commit antiguo a una máquina de despliegue sin perder ninguno de los commits intermedios.

Source: https://stackoverflow.com/a/56710884

git checkout 307a5cd        # check out the commit that you want to reset to 
git checkout -b fixy        # create a branch named fixy to do the work
git merge -s ours master    # merge master's history without changing any files
git checkout master         # switch back to master
git merge fixy              # and merge in the fixed branch
git push                    # done, no need to force push!

Gráficamente ocurrirá esto:

c1 -- c2 -- c3 -- c4 -- c2' -- c5 ...
        \              /
         '------------'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment