繁体   English   中英

来自其他分支的文件在master分支中可见

[英]Files from other branches visible in master branch

我正在学习git。 我从master分支创建了一个新的NEW分支,并在NEW创建了一个新文件。 现在,当我切换回master时,在master分支中可以看到在NEW新创建的文件。 正常吗 如果是这样,如何隐藏master分支中其他分支的文件。

直到您添加它( git add <file> )并提交它( git commit -m 'My new file' ),才跟踪新创建的文件。 这意味着git不知道其在索引树中的存在。

因此,您描述的行为是完全可以预期的。 架构可以帮助您理解( )。

请尝试以下操作:

git checkout master          # start from the master branch
git checkout -b NEW          # create and switch onto the NEW branch
echo foo > bar               # create a new file
git add bar                  # track the file
git commit -m 'My new file'  # Commit the new file
git checkout master          # The file has disappeared from the working directory

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM