切换git分支不更新文件

4

我创建了一个新的分支并添加了一些文件。

在本地,我使用 Tortoise GIT,当我切换到新分支时,文件会被更新。

但是,在我的生产服务器上使用 CLI 时,当我使用 git checkout mynewbranch 切换到新分支时,文件不会被更新。

当我使用 git checkout origin/mynewbranch 切换时,文件会被更新,但我会收到以下消息:

You are in 'detached HEAD' state. You can look around, make
experimental changes and commit them, and you can discard any commits     
you make in this state without impacting any branches by performing 
another checkout.

为什么会这样?
1个回答

11

看起来你已经有一个名称为mynewbranch的本地分支,但是这个分支没有你想要的最新更改。然而,这些更改确实存在于源代码中。因此,当你执行git checkout origin/mynewbranch时,你就可以看到这些更改。如果你想将这些更改拉入你的本地mynewbranch分支,可以执行以下命令:

git checkout mynewbranch
git pull . origin/mynewbranch

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接