Git 提交后拉取 'Already up-to-date'

Git pull gives 'Already up-to-date' after committing

我正在做一个使用两个不同虚拟机的项目。在第一个上,我创建了一个文件,我将其添加、提交并推送到存储库。稍后,我将存储库克隆到另一个 VM 上。然后我回到第一个 VM 对文件进行一些更改以添加并提交更改,然后拉入第二个 VM。问题是我没有得到已完成的更改,它说:Already up-to-date.

在克隆虚拟机上,git log 输出:

root@master:/home/test/hello/learning# git log
commit 1f15a20164b57303d1cc8bb8f518b4560ad44ad9
Author: test <test@stud.cn.no>
Date:   Tue Jan 13 14:30:33 2015 +0000

    2nd

commit 77950eb49e28aadd49ddb78b9a48701c4ecb910a
Author: test <test@stud.cn.no>
Date:   Tue Jan 13 14:27:53 2015 +0000

    Forste

在我创建存储库的 VM 上,git log 给出:

root@python:/home/ubuntu/learning# git log
commit 89fead2b83d16373723d06954a0f4f29a695d6f4
Author: test <test@stud.cn.no>
Date:   Tue Jan 13 14:34:31 2015 +0000

    NA

commit 1f15a20164b57303d1cc8bb8f518b4560ad44ad9
Author: test <test@stud.cn.no>
Date:   Tue Jan 13 14:30:33 2015 +0000

    2nd

commit 77950eb49e28aadd49ddb78b9a48701c4ecb910a
Author: test <test@stud.cn.no>
Date:   Tue Jan 13 14:27:53 2015 +0000

    Forste

并且 git status 给出:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)

您忘记了 push 您的新提交,git status 的输出实际上告诉您:

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.  <--- Right here
#
nothing to commit (working directory clean)

记住Git是分布式的。几乎所有你做的事情都只存在于你的本地机器上,直到你明确地共享它,通常是通过 运行 之类的 git pushgit push origin master.