[英]Move multiple unrelated uncommitted changes into several branches
Some files have been changed and some added, and nothing committed to master. 有些文件已更改,有些文件已添加,但没有文件提交给主文件。 I would like to checkout a new branch "login_fix" and commit the changes to two files to that branch (and probably merge it back into master immediately if the fix works).
我想签出一个新的分支“ login_fix”,并将对两个文件的更改提交到该分支(如果修复有效,可能会立即将其合并回master)。 The rest of the files, some new and some modified, I would either commit to a different new branch, "big_mess," or I guess leave as uncommitted files if that is even possible.
其余的文件(有些是新的,有些是修改的),我要么提交到另一个新分支“ big_mess”,要么我认为如果可能的话,将它们保留为未提交的文件。
Can I do that with git commands? 我可以使用git命令吗?
My other option is to tar
all these files, git reset --hard HEAD
, and then untar the files somewhere else and copy in the new files for each branch I want to create out of them. 我的另一种选择是
tar
所有这些文件, git reset --hard HEAD
,然后解压缩文件的其他地方复制在每个分支我想创造出他们的新文件。
git status
shows: git status
显示:
On branch master
Your branch is up-to-date with 'origin/master'.
And it shows about 10 modified files and 6 added files, 2 of which appear to be renamed backup copies of files that were modified. 它显示了大约10个修改的文件和6个添加的文件,其中有2个似乎是重命名的已修改文件的备份副本。
Yes, you can. 是的你可以。 Do the following
请执行下列操作
On the "login_fix" branch do 在“ login_fix”分支上
git commit <file_1> <file_2>
Get the commit id(SHA value) of above commit using 使用获取上述提交的提交ID(SHA值)
git log
Now go to your master and do following. 现在去找你的主人,并按照以下步骤进行。 The "SHA_value" is the commit id you got from above "git log" command.
“ SHA_value”是您从“ git log”命令上方获得的提交ID。
git cherry-pick <SHA_value>
If you want to leave the remaining files as uncommitted then you do not need to do anything. 如果要将其余文件保留为未提交状态,则无需执行任何操作。 If you want to commit them to the branch "big_mess", then go to that branch and do
如果要将它们提交到分支“ big_mess”,请转到该分支并执行
git commit <list_of_remaining_files>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.