I made few local changes in the master in git repository and released I have to create a new branch. I created a new branch and committed the changes using
我在git存储库中的master中做了很少的本地更改并且发布了我必须创建一个新的分支。我创建了一个新分支并使用了更改
git checkout -b changes
git add <files>
git commit -m "new feature in branch"
The name of modified file is "run.pl". Before the new branch, git status on master was
修改后的文件名是“run.pl”。在新分支之前,master上的git status是
On branch master
Changes not staged for commit
modified run.pl
Untracked files
build1.pl
After the new branch, git status in master is
在新分支之后,master中的git status是
On branch master
Untracked files
build1.pl
I could not understand how git status on master can change when I committed the changes only to a branch
当我将更改仅提交给分支时,我无法理解master上的git状态是如何更改的
1 个解决方案
#1
1
I made few local changes in the master
我在主人身上做了很少的局部变化
That's not actually what you did. You made changes to the files in the directory. Until you commit those changes, they're not "on" any branch, they only exist in the working directory.
这实际上并不是你做的。您对目录中的文件进行了更改。在您提交这些更改之前,它们不会“在”任何分支上,它们只存在于工作目录中。
The "status" in question is the state of the working directory, compared to the branch that you're currently working on, which was master.
有问题的“状态”是工作目录的状态,与您当前正在处理的分支(即master)相比。
It's not that modifying one branch changes the status in another, it's that you've changed the status of your working directory. When you switched branches, the uncommitted changes stayed put. When you committed those changes to the new branch, they were no longer untracked, so Git no longer has any untracked changes to report to you.
并不是修改一个分支会改变另一个分支的状态,而是你已经改变了工作目录的状态。切换分支时,未提交的更改仍然存在。当您将这些更改提交到新分支时,它们不再是未跟踪的,因此Git不再有任何未跟踪的更改来向您报告。
#1
1
I made few local changes in the master
我在主人身上做了很少的局部变化
That's not actually what you did. You made changes to the files in the directory. Until you commit those changes, they're not "on" any branch, they only exist in the working directory.
这实际上并不是你做的。您对目录中的文件进行了更改。在您提交这些更改之前,它们不会“在”任何分支上,它们只存在于工作目录中。
The "status" in question is the state of the working directory, compared to the branch that you're currently working on, which was master.
有问题的“状态”是工作目录的状态,与您当前正在处理的分支(即master)相比。
It's not that modifying one branch changes the status in another, it's that you've changed the status of your working directory. When you switched branches, the uncommitted changes stayed put. When you committed those changes to the new branch, they were no longer untracked, so Git no longer has any untracked changes to report to you.
并不是修改一个分支会改变另一个分支的状态,而是你已经改变了工作目录的状态。切换分支时,未提交的更改仍然存在。当您将这些更改提交到新分支时,它们不再是未跟踪的,因此Git不再有任何未跟踪的更改来向您报告。