If you need to overwrite all commits on a branch , try the following steps : Check out the branch for which you want to overwrite all commits in one commit. Let’s say its called, feature_branch.

git checkout feature_branch

Step 1

Perform a soft reset of your origin / feature_branch with your local branch masters (depending on your needs, you can also reset with origin / master). This will reset any additional commits in your feature_branch, but without locally modifying your file changes.

git reset --soft master

Step 2

Add all the changes in your git repo directory, to the new commit that will be created. And engage the same with a message.

git add -A && git commit -m "commit message goes here"

Also read : How to change the commit message after a push ? , you can also download the last version of git from here.


  1. Pingback: (SOLVED) Git - How to undo the last local commits ? » JavaTuto

Laisser un commentaire