简体   繁体   中英

Merge multiple branches into master with all the files

I'm using Git to version control my thesis although I'm quite a Git noob.

I put each chapter in a separate branch which is recommended on the web. But now as I mostly finished all of them, I just wanted to merge them into master, or only to gather them together so that I can use pandoc to merge those separate files into one.

I thought it could work simply by doing

git merge branch1 branch2 ...

But it failed which I guess was due to some commits, it says

Should not be doing an Octopus.
Merge with strategy octopus failed.

Then I tried what was suggested online

git merge branch1 branch2 ... --strategy=ours

It turned out that It did put all of the commits from all branches together, but no files showed up.

So what should be the right way to do this in my situation? Thanks!

FYI: all my files in different branches have unique names.

Update: I think the reason that the merge fails is this: there was separte README file in each branch which I later deleted but kept one in master. So even if I merge all the branches separately I still have to fix the conflicts every time.

$ git merge abstract
CONFLICT (modify/delete): README.md deleted in abstract and modified in HEAD. Version HEAD of README.md left in tree.
Automatic merge failed; fix conflicts and then commit the result.

My goal is simply to have all my files for the chapter in one place.

As far as I see it, the message "Should not be doing an Octopus" indicates that there are conflicts which cannot be resolved automatically. Octopus merges are intended for simple merges only that resolve without any conflict.

In your case, I'd suggest to perform one merge per branch.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM