git tortoisegit 与分支一起工作并与原点合并

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14978782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:12:11  来源:igfitidea点击:

tortoisegit working with branches and merging with origin

gittortoisegitassembla

提问by user1929393

I would like to know what is the best way to merge 1 changed file in your branch back to the source origin branch, but do not want to push all the changed files, as I have many changed files not ready to be merged. For example, can I push just 1 changed file to merge, instead of 3 files that have changed from my branch. Is there a way to set the ones you do not want to merge to a specific setting in tortoisegit?

我想知道将分支中 1 个更改的文件合​​并回源源分支的最佳方法是什么,但不想推送所有更改的文件,因为我有许多更改的文件尚未准备好合并。例如,我可以只推送 1 个已更改的文件进行合并,而不是从我的分支中更改的 3 个文件。有没有办法将您不想合并的设置设置为 tortoisegit 中的特定设置?

回答by Wilbert

Yes, it's possible.

是的,这是可能的。

First, you should create a local branch that exactly mirrors the remote origin branch. I will tell you the command line commands, but of course you can also use Tortoise Git. We use 'tmp' as name for the temporary local branch, 'src' as the local branch you are currently working with and assume the remote branch name is remotebranchname.

首先,您应该创建一个完全反映远程源分支的本地分支。我会告诉你命令行命令,当然你也可以使用 Tortoise Git。我们使用 'tmp' 作为临时本地分支的名称,使用 'src' 作为您当前正在使用的本地分支,并假设远程分支名称是 remotebranchname。

$ git fetch origin
$ git branch -b tmp origin/remotebranchname

Next, you get the single changed file. If you made a nice, single commit with the changes for that file, you can use 'cherry-pick' to only transfer this one commit. I will assume you did not make those changes in a single commit, therefore we make a new one:

接下来,您将获得单个更改的文件。如果您对该文件的更改进行了一次不错的单次提交,则可以使用“cherry-pick”仅传输此一次提交。我假设您没有在一次提交中进行这些更改,因此我们进行了新的更改:

$ git checkout src mychangedfile

This will fetch the changed file into your tmp branch. Now you can make a new commit, and finally you can push this branch to origin/remotebranch.

这会将更改后的文件提取到您的 tmp 分支中。现在您可以进行新的提交,最后您可以将此分支推送到 origin/remotebranch。

On a side note, I would recommend you to try out Git Extensions. I feel that working with Git in Windows is easier using Git Extensions than Tortoise Git.

附带说明一下,我建议您尝试使用Git Extensions。我觉得在 Windows 中使用 Git 比使用 Tortoise Git 更容易使用 Git 扩展。