Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

git - GitHub "can't automatically merge"?

Sometimes when i try to merge the head fork into my base fork, or my base fork into the head fork, I get the following message on GitHub:

"Can’t automatically merge. Don’t worry, you can still create the pull request."

How do I view the conflicts, if there are any for this?

I have read about 10 different examples with various commands but I can't tell what the names in the examples apply to in my situation as different names for bases, forks, branches, etc, exist.

After all of this, I can't believe there isn't a command you can type to see the conflicts, edit the conflicts and go on with merging. If there is, I haven't found it yet.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That means that your pull request can't be merged into the upstream without the upstream owner(s) having to resolve merge conflicts.

The resolution here would be for you to do a fetch from the upstream and then resolve the merge conflicts from the upstream. At this point, if you theoretically resolve the conflicts from the upstream and then create your pull request, upstream would be able to automatically merge in your pull request without having any conflicts (provided there were no commits on the upstream between you locally resolving the upstream merge conflicts and merging into your local/fork, and then creating the pull request).

Let's use GitHub as an example here for remote repo store.

OriginalAccount epo1 - say this is the original repository (we will refer to this as "upstream")

YourAccount epo1 - this would be your fork of the repository (this is typically the "origin" remote)

repo1 local - this is your local copy of the repository.

When you create a pull request from YourAccount epo1 to OriginalAccount epo1 (virtually from origin to upstream), seeing the message that you can't merge automatically means that OriginalAccount epo1 has commits that YourAccount epo1 doesn't have (commits that were most likely pushed after you forked).

The solution here would be to fetch from upstream to your local repository (from OriginalAccount epo1 to your local repo) and resolve any merge conflicts locally. Then push your commits to YourAccount epo1. At this point, you should be able to create your pull request that should be able to be automatically merged into OriginalAccount epo1.

Note: Even though most Git services won't prevent you from continuing on with a pull request that requires the upstream contributors to resolve merge conflicts, it is good practice and good etiquette to ensure that your pull request merges with no conflict. Think about it like this, you should be doing the merge conflict resolution work, instead of having the upstream contributors doing that work from your contribution.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...