新文件显示在多个分支中 [英] new files showing in multiple branch
问题描述
我在一个名为new的分支中创建了一些文件,并在那里添加了一些文件。
但是,这些新文件也显示在master中。
$ git分支
gh-pages
*主
修改
新
$ git status
在分支大师
您的分支是最新的'origin / master'。
未记录的文件:
(使用git add< file> ...来包含将要提交的内容)
scalable / apps / dbeaver.svg
可扩展/ apps / kazam.svg
可扩展/ apps / mysql-workbench.svg
没有添加提交但未跟踪文件存在(使用git add跟踪)
$ git checkout new
转换到分支'new'
$ git status
分支上新增
未记录文件:
(使用git add< file> .. 。包含在将承诺的内容中)
scalable / apps / dbeaver.svg
scalable / apps / kazam.svg
scalable / apps / mysql-workbench.svg
没有添加任何内容提交,但未跟踪的文件存在(使用git add跟踪)
这是正常的吗?
这是绝对正常的, git status
告诉你为什么:
没有添加任何内容来提交,但未跟踪的文件存在egit add来跟踪)
Git还没有跟踪这些文件。他们不属于任何分支,因为他们从未提交到存储库。
您必须 git commit
以使这些文件属于提交。分支只是一个指向提交的指针。
I have created some files in a branch called "new", and added some file there. But, those new files are shown in master as well.
$ git branch
gh-pages
* master
modify
new
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
scalable/apps/dbeaver.svg
scalable/apps/kazam.svg
scalable/apps/mysql-workbench.svg
nothing added to commit but untracked files present (use "git add" to track)
$ git checkout new
Switched to branch 'new'
$ git status
On branch new
Untracked files:
(use "git add <file>..." to include in what will be committed)
scalable/apps/dbeaver.svg
scalable/apps/kazam.svg
scalable/apps/mysql-workbench.svg
nothing added to commit but untracked files present (use "git add" to track)
Is this normal?
It is absolutely normal and the last sentence of the output of git status
tells you why:
nothing added to commit but untracked files present (use "git add" to track)
The files are not tracked by Git yet. They do not belong to any branch because they were never committed to the repository.
You must git add
then git commit
in order to make those file belong to a commit. A branch is just one pointer to a commit.
这篇关于新文件显示在多个分支中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!