0

I have master look like

|
|
abcd3    Commit3 (file A, B)
|
|
abcd2    Commit2 (file C, D)
|
|
abcd1    Commit1 (file E)
|
|

and in my feature branch

xyz1     MyCommit (file A, B)
|
|
abcd1    Commit1 (file E)
|
|

When I merge master -> feature, it conflict. I resolved and have

xyz3     ResolveConflictAndMyNewCommit (file X, Y)
|
|
xyz2     Merge branch master into feature
|
|
xyz1     MyCommit (file A, B)
|
|
abcd1    Commit1 (file E)
|
|

So I want my feature branch now look like

|
|
xyz      MyCommit (file A, B, X, Y)
|
|
abcd3    Commit3 (file A, B)
|
|
abcd2    Commit2 (file C, D)
|
|
abcd1    Commit1 (file E)
|
|

Does git have command for this case? I tried squash but still can't make my feature branch look like result. Beside that feature branch has been pushed, I need a solution to clear history in this branch, thank you!!!

Thang Hoang
  • 95
  • 2
  • 11
  • Why do you want that? Are you trying to hide the fact that the merge happened? – matt Jun 19 '21 at 04:13
  • 1
    I have a lot of merge commit ( > 10) and resolve, so I want to clean up all commit into 1 commit. That branch will be more friendly – Thang Hoang Jun 19 '21 at 04:28
  • 1
    You can always just reset soft back to before the complexity and make a single new commit. – matt Jun 19 '21 at 04:44
  • 1
    But it will contain all changed filed from merge commit, I only want to create commit from file I changed, not from other commit, so I think reset --soft is not right – Thang Hoang Jun 19 '21 at 05:12
  • 3
    That's meaningless. Every commit contains _all_ your files. – matt Jun 19 '21 at 05:22
  • 1
    Sorry that late reply because my deadline. Yeah, I agree with you "every commit contains all your files". In my opinion, I just want to know how to clean up history, and the keyword right now is "rebase merged commit", it look like: https://stackoverflow.com/questions/4783599/rebasing-a-git-merge-commit. Thank you! – Thang Hoang Jul 08 '21 at 09:14

0 Answers0