简体   繁体   English

每当我创建一个新分支时,它都会显示存储在 master 分支中的所有文件,它应该是空的

[英]Whenever I create a new branch it shows all files stored in master branch that it should be empty

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git branch
* master

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ ls -l
total 0
-rw-r--r-- 1 user 197121 0 Jun 12 10:43 file1.py

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git branch part1

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git checkout part1
Switched to branch 'part1'

user@LAPTOP-LNQB4U6E MINGW64 ~/store (part1)
$ git branch
  master
* part1

user@LAPTOP-LNQB4U6E MINGW64 ~/store (part1)
$ ls -l
total 0
-rw-r--r-- 1 user 197121 0 Jun 12 10:43 file1.py
user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git branch
* master

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ ls -l
total 0
-rw-r--r-- 1 user 197121 0 Jun 12 10:43 file1.py

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git branch part1

user@LAPTOP-LNQB4U6E MINGW64 ~/store (master)
$ git checkout part1
Switched to branch 'part1'

user@LAPTOP-LNQB4U6E MINGW64 ~/store (part1)
$ git branch
  master
* part1

user@LAPTOP-LNQB4U6E MINGW64 ~/store (part1)
$ ls -l
total 0
-rw-r--r-- 1 user 197121 0 Jun 12 10:43 file1.py

That seems expected:这似乎是意料之中的:

  • either file1.py was not tracked (added/commited) to the master branch, and that private file would not disappear just because you are creating a branch要么file1.py没有被跟踪(添加/提交)到主分支,并且该私有文件不会仅仅因为您正在创建一个分支而消失

  • or file1.py was part of the master branch, and creating a new branch from there would start with the master branch content.file1.py是 master 分支的一部分,从那里创建一个新分支将从 master 分支内容开始。

Only creating an orphan branch ( git switch --orphan ) would start with an empty content.只有创建孤立分支( git switch --orphan )才会以空内容开始。

Note: if you are using Git 2.23 or more recent, use git switch , not the confusing git checkout old command .注意:如果您使用的是 Git 2.23 或更高版本,请使用git switch ,而不是令人困惑的git checkout old command

暂无
暂无

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

相关问题 如何从git导出所有分支更改的文件与本地主文件相比 - how to export all branch changed files compared to local master from git 如何将更改从master转移到Feature分支 - How can I get changes from master into feature branch 如何将主分支文件夹添加到github页面? - How to add master branch folder to github pages? 如何将master合并到github中的Windows分支中? - how to merge master into branch in github for windows? Git/Windows - 签出分支(以及拉取/合并分支)时区分大小写的问题。 受影响的文件在 Windows 资源管理器中全部为小写 - Git/Windows - Case sensitivity issues when checking out a branch (and pulling/merging a branch). Affected files are all lowercase in Windows Explorer GIT:如何使用 git 命令获取从主分支到自定义分支的最新更改? - GIT : How to get latest changes from master branch to the custom branch using git commands? 如何重置整个Git存储库,而不只是重置“ Master”分支,以匹配Remote? - How to reset the entire Git repository, and not only the “Master” branch, to match Remote? Git:如何更新master分支,一步切换到master分支? - Git: How to update the master branch and switch to it in one step? 擦除和取消主分支会影响我的其他分支吗 - Does erasing and repulling a master branch affect my other branches 在Windows中创建具有不同大写字母的新分支 - Creating a new branch with different caplitalization in windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM