使用git,如何将一些未提交的更改从一个分支移动到另一个文件夹中的另一个分支? [英] Using git, how do you move some uncommitted changes from one branch to another branch in a different folder?

查看:77
本文介绍了使用git,如何将一些未提交的更改从一个分支移动到另一个文件夹中的另一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每天都使用同一软件的两个不同分支.但是,每次结帐另一个分支时,我的构建过程可能需要一个小时.为了解决这个问题,我刚刚在两个单独的文件夹中为每个分支签出了该项目一次.

我在一个分支中做了一些工作,并在提交之前意识到我在错误的文件夹中,因此在错误的分支中.我如何才能将在该分支上所做的工作移到另一个分支,最好不要创建提交(如果可能的话)?

解决方案

在包含更改的目录中,执行以下操作:

$ git diff > patch

cd到另一个目录,然后执行:

git apply /path/to/patch

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:

git apply /path/to/patch

这篇关于使用git,如何将一些未提交的更改从一个分支移动到另一个文件夹中的另一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆