我有一个本地分支机构,我没有做任何改动。然后我做
git checkout anotherbranch
# Switched to branch 'anotherbranch'
# Your branch is behind 'origin/anotherbranch' by 25 commits, and can be fast-forwarded.
# (use "git pull" to update your local branch)
所以我需要拉动以获得所有最新的变化。我这样做
git pull origin anotherbranch
我希望现在一切都是同步的,但不是因为
git status
On branch anotherbranch
Your branch is ahead of 'origin/anotherbranch' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
这是因为git pull的合并部分又添加了两个提交吗?但是,当我执行git log时,这些提交不会显示。取而代之的是另一位作者提交的两份提交。推动他的两次承诺让我觉得不对。实际上我不想推送任何东西,只是更新我的本地分支。我怎样才能做到这一点?如果git pull是一个错误,我怎么能恢复它而不会产生其他现实或其他git恐怖(我没有推动任何东西,除了另一个功能分支)
答案 0 :(得分:0)
git status
On branch anotherbranch
Your branch is ahead of 'origin/anotherbranch' by 2 commits.
(use "git push" to publish your local commits)
这意味着您有2个未被推送的提交。
最好的做法是运行
git fetch
偶尔获取所有服务器元数据(更新已删除的分支,新提交等)
此命令的结果是什么:
git log --oneline
它会显示所有提交的日志,所以你可以看到问题是什么
答案 1 :(得分:-1)
好的,所以在我做之前 git checkout anotherbranch 我需要去做 git rebase origin / anotherbranch 这样做是没有错的,因为我在私人功能分支上。