背景:
我认为这是一个简单的场景。我已经在本地提交了更改,现在我想将远程分支(领先于我)上的内容合并到本地的工作目录中。
git branch -vv --list --all
的输出如下:
master 79d9d4e [origin/master: behind 7] Footprint UI working
remotes/origin/HEAD -> origin/master
remotes/origin/master a86a1a9 Added sample data to webpage
我希望合并其中的一个文件。以下是差异:
git diff --stat a86a1a9 79d9d4e views/footprint.handlebars
views/footprint.handlebars | 65 +++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 33 insertions(+), 32 deletions(-)
但是当我运行
git pull
命令时,本地提交的文件版本被远程覆盖了。更详细地说:$ git fetch -v origin
From github.com:githubusername/foo
= [up to date] master -> origin/master
$ git merge origin
Updating 79d9d4e..a86a1a9
Fast-forward
...
views/footprint.handlebars | 65 ++++++++++++++++++++++++++++++++---------------------------------
...
6 files changed, 220 insertions(+), 59 deletions(-)
create mode 100644 static/search.js
create mode 100644 views/search.handlebars
我已阅读以下帖子: 我尝试了以下命令:
git pull --rebase
会覆盖文件的本地版本git merge -s recursive -X ours
会覆盖本地文件的版本git merge -s ours
提示输入提交信息,然后覆盖远程更改git rebase remotes/origin/master
表示将在“head”上“重放我的工作”,但仍会覆盖它git merge --no-ff --no-commit
当覆盖文件时,字面上报告“自动合并进行得很好;根据要求停止提交”
git reset --hard master@{"5 minutes ago"}
)$ git config --list
redential.helper=osxkeychain
user.name=My Name
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.precomposeunicode=true
remote.origin.url=git@github.com:githubusername/foo.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.email=email@address.com
remote.heroku.url=https://git.heroku.com/foo.git
remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*
$ git log --oneline --decorate --simplify-by-decoration --all -10
a86a1a9 (origin/master, origin/HEAD) Added sample data to webpage
79d9d4e (HEAD -> master) Footprint UI working
c53160d Initial commit
$git log --format="%h %ci %cn" views/footprint.handlebars
79d9d4e 2019-03-12 19:04:08 -0400 chb
fada3fa 2019-03-10 13:59:41 -0700 JA
9641499 2019-03-08 16:48:14 -0800 JA
1759509 2019-03-08 12:32:08 -0800 GitHub
bfe443e 2019-03-07 16:41:18 -0800 JA
git version 2.17.2 (Apple Git-113)
问题:
为什么git
没有将此冲突标记为冲突并在相关文件中添加适当的标记(<<<<<<< HEAD
, =======
, >>>>>>>
)?
git config --list
的输出吗?就像你所链接的第二个问题的答案所指出的那样,这可能会受到你的 git 配置的影响(请注意,仅查看.git
是不够的,那不是 git 使用的唯一位置)。 - Michailgit merge origin/whatever
。其实应该说“手动合并调用”,或者干脆不提。我通常做什么在这里有点不相关。 - Michailmaster
上了(如果文件内容有误,则可能已被其他提交覆盖),或者不在本地master
上(不幸的是git reset
,或者可能是你不小心在其他分支上工作,或者类似的情况)。抱歉,我无法继续了,这里已经是凌晨3点了。祝你好运! - Michailgit merge
输出,您的同事在合并时犯了一个错误。 - Ferrybig