[英]Using git, how do you move some uncommitted changes from one branch to another branch in a different folder?
I have two different branches of the same software that I work on every day. 我每天都在使用相同软件的两个不同分支。 However, every time I checkout the other branch, my build process can take up to an hour. 但是,每次我签出另一个分支时,我的构建过程可能需要一个小时。 To solve this, I have just checked out the project once for each branch in two separate folders. 为了解决这个问题,我刚刚在两个单独的文件夹中为每个分支检查了一次项目。
I did some work in one branch, and realized before committing it that I was in the wrong folder, and thus the wrong branch. 我在一个分支中做了一些工作,并在提交之前意识到我在错误的文件夹中,因此错误的分支。 How can I move the work I did on this branch, to the other branch, preferably without creating a commit (if that is even possible)? 如何将我在此分支上所做的工作移动到另一个分支,最好不要创建提交(如果可能的话)?
In the directory with the changes, do: 在包含更改的目录中,执行以下操作:
$ git diff > patch
cd to the other directory, and do: cd到另一个目录,然后执行:
git apply /path/to/patch
Well, you can also not build the other branch.. 好吧,你也可以不建立其他分支..
Naturally, this only works if you can allow yourself to commit without building (reasonable in some scenarios). 当然,只有在没有构建的情况下允许自己提交(在某些情况下是合理的)时,这才有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.