I have repo with a single branch and numerous commits.
I want to squash all commits into one.
I do:
git rebase --root -i
(see: How to squash all git commits into one? )
after setting all commits to squash (except the first, set to "pick") and exiting the editor, the interactive rebase stops and asks me to solve some conflicts.
I am quite confused about this. I understand conflicts when merging a branch into another. I do not understand it when squashing: should not be the newer commit be automatically considered as the "correct" version of the file? Also, several files have been modified throughout the commits, how come only a very few of them show conflicts?
As hinted by @mnestorov's comment: you probably have merged branches in your history.
If your intention is to throw away a chunk of history and simply squash commits together, you can do so without using git rebase
.
Just run git reset --soft [target commit]
, followed by git commit
or git commit --amend
.
The first one will create a new commit on top of [target commit]
, the second will rewrite [target commit]
in place.
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.