git:创建新的本地分支,没有任何本地未提交的更改 [英] git: Create new local branch without any local un-committed change
问题描述
我在本地分支A上做了一些没有提交的更改(他们没有完成)。然后,我想创建一个新的分支B(以处理不同的事情),而不引入分支A中的更改。如果我执行'git checkout -b B',分支A中的更改将被带到新分支B.我怎样才能避免这种情况?我想要一个全新的分支B,而不需要更改分支A,而且我现在不想在A中提交更改,因为它们尚未完成。
谢谢你们!
您可以在签出新分店前存储您的更改。
git stash
git checkout -b B
如果您有一些新的未跟踪文件,并且您希望它们也一样,则可以先添加它们(但不提交): $ c> git add。
git stash
git checkout -b B
稍后,您将可以通过$ / $>
$ b
git重置HEAD文件
I'm on local branch A and did some changes without committing (they are not done). Then I want to create a new branch B (to work on something different) without bringing in the changes in branch A. If I do 'git checkout -b B', the changes in branch A will be brought to the new branch B. How can I avoid this? I want a brand new branch B without the changes in branch A, and I don't want to commit the changes in A at this moment because they are not finished.
Thanks guys!
You can stash your changes before checking out a new branch.
git stash
git checkout -b B
If you have some new untracked files and you want them gone too, you can first add them (but not commit):
git add .
git stash
git checkout -b B
Later you will be able to untrack them by
git reset HEAD file
这篇关于git:创建新的本地分支,没有任何本地未提交的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!