0

In a repo, I have the main master branch that the team uses. I have developed a new feature on another branch called feature. I then merged this feature branch with master using:

git checkout master
git merge feature

However, I forgot to squash the commits from the feature branch. There were 81 commits on that branch, and now I can see all of those in master. I want to undo this merge, and redo it with the --squash argument so that all of these 81 commits are squashed into one. How can I do this? There are a bunch of answers on undoing merges (but revert is not useful in my case because it doesn't remove the 81 commits from the commit history, it just adds a new commit reverting the changes) and I wasn't sure a hard reset to the previous commit id would erase all of these commits from the master commit history.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
RaviTej310
  • 1,635
  • 6
  • 25
  • 51
  • 2
    Does this answer your question? [Rollback a Git merge](https://stackoverflow.com/questions/11722533/rollback-a-git-merge) – pkamb Mar 17 '21 at 21:58
  • I don't think so, I tried a hard reset and it didn't erase all of the 81 commits from master. Note that these 81 commits are interleaved with other commits that other people made to the master branch – RaviTej310 Mar 17 '21 at 22:34
  • The answer @pkamb linked to is exactly the solution to your problem. You didn't do it right if it doesn't work. – jingx Mar 17 '21 at 23:35

0 Answers0