Git新文件出现在所有分支中 [英] Git new file appears in all branches
问题描述
我认为在一个分支上创建的文件不会出现在其他分支中,直到我合并或重新分支分支为止。
我有两个分行:
$ b
- master
- new_contact_page
我检出 new_contact_page 分支。
$ git checkout new_contact_page
然后我创建一个新文件。
$ vi contact_page.html
没有执行任何Git命令,我切换回 Master 分支。
$ git checkout master
然后我看到这个contact_page.html文件也在我的 Master 分支中。
$ ls(contact_page.html显示在列表中! )
不应该只存在于 new_contact_page 分支中吗?
Git永远不会触及任何实际不在您的资源库中的文件。 (未跟踪的文件)
您需要 git add
和 git commit $ c首先将文件放到一个分支中。
I thought a file created on one branch will not appear in any other branches until I merge or rebase the branch?
Example:
I have two branches:
- master
- new_contact_page
I checkout the new_contact_page branch.
$ git checkout new_contact_page
Then I create a new file.
$ vi contact_page.html
Without doing any Git commands, I switch back to my Master branch.
$ git checkout master
Then I see that this contact_page.html file is also in my Master branch.
$ ls (contact_page.html shows up in the list!)
Shouldn't the file only exist in new_contact_page branch?
Git will never touch any files that aren't actually in your repository. (untracked files)
You need to git add
and git commit
the file (into one branch) first.
这篇关于Git新文件出现在所有分支中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!