git status on master and branches

不羁岁月 提交于 2019-12-06 14:42:38

问题


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 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

On branch master
Changes not staged for commit
       modified run.pl

Untracked files
       build1.pl

After the new branch, git status in master is

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


回答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.

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.



来源:https://stackoverflow.com/questions/22796711/git-status-on-master-and-branches

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!