我有一个项目,我想在master上创建一个分支。我是该项目的新手,之前从未参与过该项目,但是当我执行git pull
以获取最新更改时,我立即遇到了合并冲突。
绝对不是我之前从未在该项目上做过任何工作的期望。
我该如何解决?
git pull
的实际外观如下:
git pull
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 46 (delta 29), reused 37 (delta 25), pack-reused 0
Unpacking objects: 100% (46/46), done.
From github.com:ldco2016/project
7c36686..8c495a6 master -> origin/master
* [new branch] fix/task-uuid-assignment -> origin/fix/task-uuid-assignment
Auto-merging mix.lock
CONFLICT (content): Merge conflict in mix.lock
Auto-merging mix.exs
CONFLICT (content): Merge conflict in mix.exs
Auto-merging lib/project/schema.ex
CONFLICT (add/add): Merge conflict in lib/project/schema.ex
Auto-merging lib/project/router.ex
CONFLICT (content): Merge conflict in lib/project/router.ex
Auto-merging lib/project/resolvers/content.ex
CONFLICT (add/add): Merge conflict in lib/project/resolvers/content.ex
Auto-merging lib/project/endpoint.ex
Auto-merging lib/project/context.ex
CONFLICT (add/add): Merge conflict in lib/project/context.ex
Auto-merging lib/project/channels/user_socket.ex
CONFLICT (content): Merge conflict in lib/project/channels/user_socket.ex
Auto-merging lib/project/account/account.ex
Automatic merge failed; fix conflicts and then commit the result.
我尝试了此修复程序:
git pull --rebase
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
但显然,它没有用。
然后我尝试:
git reset --hard
HEAD is now at eb96cbf Require authentication on all types except auth
➜ project git:(master) git pull --rebase
First, rewinding head to replay your work on top of it...
Applying: Install Absinthe with task and user types
Using index info to reconstruct a base tree...
M lib/project/account/account.ex
M lib/project/account/task.ex
M lib/project_web/endpoint.ex
M lib/project_web/router.ex
M mix.exs
M mix.lock
Falling back to patching base and 3-way merge...
Auto-merging mix.lock
CONFLICT (content): Merge conflict in mix.lock
Auto-merging mix.exs
CONFLICT (content): Merge conflict in mix.exs
Auto-merging lib/project_web/schema/content_types.ex
CONFLICT (add/add): Merge conflict in lib/project_web/schema/content_types.ex
Auto-merging lib/project_web/schema.ex
CONFLICT (add/add): Merge conflict in lib/project_web/schema.ex
Auto-merging lib/project_web/router.ex
CONFLICT (content): Merge conflict in lib/project_web/router.ex
Auto-merging lib/project_web/resolvers/content.ex
CONFLICT (add/add): Merge conflict in lib/project_web/resolvers/content.ex
Auto-merging lib/project_web/endpoint.ex
Auto-merging lib/project/account/account.ex
CONFLICT (content): Merge conflict in lib/project/account/account.ex
error: Failed to merge in the changes.
Patch failed at 0001 Install Absinthe with task and user types
hint: Use 'git am --show-current-patch' to see the failed patch
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
这看起来像是可行的,然后说,不,对不起,您有合并冲突。
答案 0 :(得分:0)
如果您从未尝试过,为什么不直接从源位置克隆项目,然后创建一个新分支?
另一种选择是,假设您是主用户:
git pull -f origin master
git checkout -b 'yourNewBranch'
答案 1 :(得分:0)
由于您没有要保留的本地更改,因此可以重置在合并过程中所做的所有更改:
git reset --hard
然后,再次进行git pull。