Code Review. How to modify an old commit.

Sometimes, when using Code review, you need to modify an old commit with the suggestions. I used to create a new commit for the modifications, but this is non clean, intuitive (if you wrap commits by task), nor backwards compatible.

There is a better way to this using git rebase, which basically allows you to change a commit and apply those changes to further commits.

In order to do that, we need to rebase the commit this way.
1º- Checkout the branch
2º- git rebase –interactive ‘xxxxxx^’
3º- In the editor, change ‘pitch’ to ‘edit’ on the commit we want to modify.
4º- Make the changes
​5º- git commit –all –amend –no-edit
6º- git rebase –continue
​7º- git push (–force) origin <branch_name>​
I hope it helps

Submit a Comment

Your email address will not be published. Required fields are marked *

Uso de cookies

Este sitio web utiliza cookies para que usted tenga la mejor experiencia de usuario. Si continúa navegando está dando su consentimiento para la aceptación de las mencionadas cookies y la aceptación de nuestra política de cookies, pinche el enlace para mayor información.

ACEPTAR
Aviso de cookies