git 分支中的修改文件溢出到另一个分支 [英] Modified files in a git branch are spilling over into another branch

查看:40
本文介绍了git 分支中的修改文件溢出到另一个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个带有主分支和另一个主题分支的 git 存储库.我已经切换到主题分支并修改了一个文件.现在,如果我切换到 master 分支,该文件将显示为已修改.

I am working on a git repository with a master branch and another the topic branch. I have switched to topic branch and modified a file. Now, if I switched to the master branch, that same file is shown as modified.

例如:

git-build 分支中的 git 状态:

git status in git-build branch:

# On branch git-build
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   cvsup_current
#

切换到主分支

[root@redbull builder_scripts (git-build)]# git co master
M       builder_scripts/cvsup_current
Switched to branch "master"

主分支中的git状态

[root@redbull builder_scripts (master)]# git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   cvsup_current
#

为什么在 git-build 分支中修改过的文件在 master 分支中显示为已修改?

Why is that the file is shown as modified in the master branch even though it was modified in git-build branch?

我的理解是分支彼此独立,当我从一个分支更改为另一个分支时,更改不会溢出".从一个分支到另一个分支.所以我显然在这里遗漏了一些东西.

My understanding was that the branches are independent of each other and when I change from one branch to another the changes do not "spill over" from one branch to another. So I am obviously missing something here.

有人有线索吗?

推荐答案

这是 git 的默认行为.

This is the default behaviour of git.

如果您愿意,您可以使用 -f 标志来结帐以进行干净结帐".

You can use -f flag to checkout to do "clean checkout" if you like.

这篇关于git 分支中的修改文件溢出到另一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆