git - 使用 Git merge 问题

标签 git github git-commit git-pull

我正在使用 git version 1.7.11.msysgit.0

我在 GitHUB 下创建了一个存储库,并添加了一个名为 README.md 的文件,其中包含一些文本内容。

后来,我安装了 GIT 客户端,做了一个克隆以将服务器内容放到我的机器上。

然后我删除了本地机器上的 README.md 文件。

现在当我执行 git commit 时,我得到了这个错误

praveenk@MSIN-BT-100 /d/workspace/MYTestRepo (master|MERGING)
$ git commit ;
U       README.md
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.

这是 git pull:

$ git pull;
U       README.md
A       One.txt
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'.

如何解决这些错误?

最佳答案

这样做:

git merge --abort
git pull (to be sure you're up-to-date)

现在用你想要的内容替换 README.md 文件的内容。如果你根本不需要它,请执行 git rm README.md

然后,如果您替换了内容,提交并推送这些内容:

git add README.md
git commit -m "comment"
git push

关于git - 使用 Git merge 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11527069/

相关文章:

git - 如何向后 rebase ,最好不使用 diff/apply?

git - Heroku Git - fatal error : The remote end hung up unexpectedly

git - "bash: __gitdir: command not found"终端错误

github - 如何更改拉取请求的基本分支?

Git - 旧提交中分支之间的差异

git - .gitignore 并没有忽略自己

git - 安装 credential-osxkeychain 后仍然提示输入凭据

python - 使用 python requests 模块在 Github 中创建经过身份验证的 session

Azure DevOps API : get latest action on the repository

git - 安卓工作室 : How to add line break in git commit message?