0

还在学习GIT。尝试将我的本地存储库与在“中央存储库”样式远程存储库上完成的提交同步。第一步是获取来源:

git fetch origin
remote: Counting objects: 1, done.
remote: Total 1 (delta 0), reused 1 (delta 0)
Unpacking objects: 100% (1/1), done.
From ssh://github.com/XXXXXX/ZZZZZZZZ
   bc2afff..3b3c8ee  master     -> origin/master

然后检查状态和分支。

git status
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
#
nothing to commit (working directory clean)

git br
* master

然后尝试--ff-only。

git merge --ff-only origin master
fatal: Not possible to fast-forward, aborting.

好的,所以做一个非 ff 合并:

git merge origin master
Fast-forwarding to: origin
Already up-to-date with master
Merge made by the 'octopus' strategy.

检查提交:

git show 4cbd3
...snip...
Merge branch 'master', remote-tracking branch 'origin'

似乎完成了非 ff 合并。合并“Fast-fowarding to: origin”的输出令人困惑——它想告诉我什么?我错过了什么?谢谢!

4

1 回答 1

1

与 eg 不同git pushgit merge它不会将远程的名称作为参数,因此当您说git merge origin master您实际上是在说“从 'origin' 和 'master' 分支进行章鱼合并”时。你应该运行的是:

git merge origin/master

显然你有一个名为“origin”的分支。它应该在那里,还是您错误地创建了它?

我不确定为什么你会在git merge origin masterand之间出现不一致的行为git merge --ff-only origin master,但这并不重要。

于 2014-01-07T02:01:12.353 回答