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

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

问题描述

我正在使用一个主分支和另一个主题分支的git存储库。我已切换到主题分支并修改了一个文件。现在,如果我切换到主分支,该文件显示为已修改。



例如:

git-build分支中的git status:

 #在分支上git-build 
#要提交的更改:
#(使用git reset HEAD< file> ...取消)

#修改:cvsup_current

切换到master分支

  [root @ redbull builder_scripts(git-build)]#git co master 
builder_scripts / cvsup_current
切换到分支master

master分支中的git状态

  [root @ redbull builder_scripts(master)]#git status 
#在分支主机上
#要提交的更改:$

#修改:cvsup_current

使用git reset HEAD< file> ...

为什么该文件在master分支中被修改,即使它在git-build分支中被修改?

我的理解是分支互相独立,当我从一个分支转换到另一个分支时,这些改变不会从一个分支溢出到另一个分支。所以我显然在这里错过了一些东西。



任何人都有线索棒?

解决方案

这是默认git的行为。

如果你愿意,你可以使用 -f 标志签出来执行clean checkout。


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

For example:

git status in git-build branch:

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

Switch to master branch

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

git status in master branch

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

Why is that the file is shown as modified in 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 some thing here.

Anyone got a clue stick?

解决方案

This is the default behaviour of git.

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

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

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