我正在尝试做一个git pull - 这是行不通的,因为我的版本和主版本有分歧。
我希望能够摆脱我所做的所有改变,并获得主版本。
这里是git status和git pull details:
C:\Users\User\Documents\Source\Project>git pull
M Gruntfile.coffee
U client/site/stylesheets/site.css
U client/site/stylesheets/site.scss
M package.json
M server/app.coffee
M server/app.js
M test/main.test.coffee
U test/main.test.js
D test/server/GetAndPost.test.js
M test/server/getAndPost.test.coffee
A test/server/getAndPost.test.js
A test/server/testStub.coffee
A test/server/testStub.test.js
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
C:\Users\User\Documents\Source\Project>git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 3 different commits each, respectively.
# (use "git pull" to merge the remote branch into yours)
#
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Changes to be committed:
#
# modified: Gruntfile.coffee
# modified: package.json
# modified: server/app.coffee
# modified: server/app.js
# modified: test/main.test.coffee
# modified: test/server/getAndPost.test.coffee
# renamed: test/server/GetAndPost.test.js -> test/server/getAndPost.test.js
# new file: test/server/testStub.coffee
# new file: test/server/testStub.test.js
#
# Unmerged paths:
# (use "git add <file>..." to mark resolution)
#
# both modified: client/site/stylesheets/site.css
# both modified: client/site/stylesheets/site.scss
# both modified: test/main.test.js
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .idea/workspace.xml
C:\Users\User\Documents\Source\Project>git add client\site\stylesheets\*
fatal: Unable to create 'C:/Users/User/Documents/Source/Project/.git/index.lock':
File exists.
If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.
#
答案 0 :(得分:0)
这不是因为你有分歧,而是因为你有需要解决的冲突。编辑标记为“已修改”的文件并解决冲突,然后添加它们。
一般来说,你应该阅读git的输出,因为它经常说明需要做什么。
答案 1 :(得分:0)
第1步:
通过运行以下命令,将“未合并路径”下的文件添加到“要提交的更改”
git add client/site/stylesheets/site.css client/site/stylesheets/site.scss test/main.test.js
(仅当您确定已修复冲突时才运行上述命令)。
第2步:
然后,通过以下命令提交“要提交的更改”部分下的文件
git commit -am "commit message"
(' - am'表示,它将使用您指定的消息在一次提交中提交所有文件)
第3步:
现在,做git pull
希望,这会对你有帮助。
由于
答案 2 :(得分:0)
请注意,添加文件是第一步
但第二个不应该是&#34; git commit -a
&#34; (比如git pull
返回)。
自Git 2.2.0 +(2014年11月)以来,您不应再看到确切的错误消息。
请参阅commit 91e70e0中的Matthieu Moy (moy
):
merge
,pull
:停止通知&#39; commit -a
&#39;如果发生冲突&#39;
git commit -a
&#39;很难将冲突标记为已解决的好方法:
无论如何,用户必须手动完成冲突列表以进行实际解决,通常最好使用&#34; git add&#34;解决后,在每个文件上。另一方面,使用&#39;
git commit -a
&#39;是有潜在危险的,因为它很容易错误地提交冲突标记而没有注意到,更糟糕的是,用户可能已经开始合并,同时具有不与其重叠的本地更改 工作树。我们在那里,同步&#39;
git pull
&#39;和&#39;git merge
&#39;消息:第一个以&#39;... and make a commit.
&#39;结尾,但不是后者。最终,git应该检测到工作树中的冲突已经解决,并进一步定制这些消息 不仅仅是&#34;
use git commit -a
&#34;可以复活,但是&#34;Fix them up in the work tree
&#34;应该在它发生时丢弃。
在您的情况下,简单的git commit -m "fix merge"
就足够了
git commit -a
存在包含太多文件的风险。