更新时间:2022-03-14 22:31:35
如果存在未提交的更改,这些更改将被git checkout
覆盖,该命令将抱怨并中止.在这种情况下,必须使用git commit
或git stash
.
If there are uncommitted changes that will be overwritten by git checkout
the command will complain and abort. In that case git commit
or git stash
is necessary.
如果存在未提交的更改,且不会被git checkout
覆盖,则命令将成功执行,并且更改将溢出到新分支中.如果不想在新分支中看到这些更改,请在git checkout
之前使用git commit
或git stash
.
If there are uncommitted changes that will not be overwritten by git checkout
the command succeeds and the changes spilled into the new branch. If you don't want to see these changes in the new branch use git commit
or git stash
before git checkout
.
与其他命令(例如git pull
和git rebase
)不同,git checkout
没有选项--autostash
,因为它没有意义:在大多数情况下,当您切换到新命令时,您不想自动执行git stash pop
分支.
Unlike other commands (like git pull
and git rebase
) git checkout
doesn't have option --autostash
because it's meaningless: in most cases you don't want to automatically do git stash pop
when switching to a new branch.