We have a practice of squashing all commits of feature branch before merging it in master branch so that we will have one commit of feature branch in master. But accidentally I merged the feature branch into master without squashing. Is there anything than can be done to to resoove the issue.
If you haven't made any commit on master after merging that feature branch, you could:
master
to the commit before that mergemaster
and notify any other member working on that repository, for them to reset their own local master
branch to that new master
HEAD.That is:
git reset --hard <SHA1 before merge>
# squash+merge
git push --force
I have 2 commits in
master
branch after the merge.
But those where my commits so I know what files I have changed.
Can I still reset my branch from the above method and then commit the next two changes again?
Yes: they can be cherry-picked and replayed on top of the new master
HEAD.
Again, once you force push ( git push --force
) that new branch history, you need to make sure any other collaborator is aware the history change, and reset his/her own local master
branch accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.