Use the following:
(使用以下内容:)
git checkout -b <new-branch>
This will leave your current branch as is, create and checkout a new branch and keep all your changes.
(这将使您当前的分支保持不变,创建并签出新分支,并保留所有更改。)
You can then make a commit with: (然后,您可以使用以下命令进行提交:)
git add <files>
and commit to your new branch with:
(并使用以下命令提交到您的新分支:)
git commit -m "<Brief description of this commit>"
The changes in the working directory and changes staged in index do not belong to any branch yet.
(工作目录中的更改和索引中暂存的更改尚不属于任何分支。)
This changes where those changes would end in. (这将更改这些更改的终止位置。)
You don't reset your original branch, it stays as it is.
(您无需重置原始分支,它会保持原样。)
The last commit on <old-branch>
will still be the same. (<old-branch>
上的最后一次提交将保持不变。)
Therefore you checkout -b
and then commit. (因此,您checkout -b
然后提交。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…