linux - git 分支,但更改反射(reflect)在 master 中

标签 linux git git-branch

<分区>

我创建了一个分支作为 git branch my_branch,然后 git checkout my_branch,在其中工作,但是当我切换回 master git checkout master 我也确实在 master 中看到了这些变化。我认为这不应该发生。

% git checkout my_branch
Switched to branch 'my_branch'

<I make my changes>

% git status
On branch my_branch
Changes not staged for commit:
...

% git checkout master
Switched to branch 'master'
% git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
...
<Shows the same changed files as in my_branch>

我可能做错了什么?

谢谢。

最佳答案

工作目录或临时区域(即索引)中未提交的更改属于任何分支。因此,当您 checkout 另一个分支时,不会影响这些更改。 git status 仍然显示它们未提交。

关于linux - git 分支,但更改反射(reflect)在 master 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50681227/

相关文章:

linux - 如果 ISR 在 Linux 中挂起会怎样?

git - 有没有办法检查两个不同的 git 提交内容是否相等?

git - 无法使用 Visual Studio Team Services 设置 Web 应用程序的部署源...找不到带指纹的证书

Git 存储库未导出 : fatal: The remote end hung up unexpectedly

git - GitHub上的origin和upstream有什么区别?

linux - 一种检测哪一侧套接字对等点触发断开连接的方法

c - 与 RPi 的 RS-232 通信

linux - 在 linux 上通过 scilab 进行串行通信

Git:master/develop/feature 分支 merge 提交

git - 什么时候删除 Git 中的分支?