主节点和分支节点上的git status [英] git status on master and branches

查看:84
本文介绍了主节点和分支节点上的git status的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在git仓库中的master上进行了一些本地更改,并释放了必须创建一个新分支的权限.我创建了一个新分支,并使用

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"

修改后的文件名为"run.pl".在创建新分支之前,master上的git status为

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

新分支之后,master中的git状态为

After the new branch, git status in master is

On branch master

Untracked files

   build1.pl

当我仅将更改提交到分支时,我不明白master上的git状态如何更改

I could not understand how git status on master can change when I committed the changes only to a branch

推荐答案

我在母版中进行了一些本地更改

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.

不是修改一个分支会更改另一个分支的状态,而是您已经更改了工作目录的状态.当您切换分支时,未提交的更改保持不变.当您将这些更改提交到新分支后,它们将不再处于未跟踪状态,因此Git不再具有任何未跟踪的更改要报告给您.

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 status的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆