git gui 分支管理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4730760/
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 04:57:12  来源:igfitidea点击:

git gui branch management

gitmsysgit

提问by Massive Boisson

Hi I am an inexperienced Git user on Windows. I am using Git Gui. I am interested in Branch Management.

嗨,我是 Windows 上没有经验的 Git 用户。我正在使用 Git Gui。我对分支机构管理感兴趣。

My repo has a branch called 'leafy', how do I check this branch out to my local machine, and them cherry pick a commit from master into leafy?

我的 repo 有一个名为“leafy”的分支,我如何将这个分支检出到我的本地机器,然后他们从 master 中挑选一个提交到多叶?

Thanks a LOT

多谢

--MB

--MB

回答by Massive Boisson

Thanks for replies, but I said I am using Git Gui

感谢回复,但我说我正在使用 Git Gui

To checkout newly created branch (exists on server, not locally), it's a 2 step process:

要签出新创建的分支(存在于服务器上,而不是本地),这是一个 2 步过程:

  1. Git Gui -> Branch -> Check Out -> Tracking Branch -> Choose Branch

  2. Branch -> Create -> Name = same name as tracking branch you chose -> Choose This Detached Checkout

  1. Git Gui -> 分支 -> 签出 -> 跟踪分支 -> 选择分支

  2. 分支 -> 创建 -> 名称 = 与您选择的跟踪分支相同的名称 -> 选择此分离结帐

You are now using the branch.

您现在正在使用分支。

Another useful and obvious thing -> to switch to another branch -> Branch -> Check Out -> Local Branch .....

另一个有用且显而易见的事情 -> 切换到另一个分支 -> 分支 -> 签出 -> 本地分支 .....

回答by Gauthier

how do I check this branch out to my local machine

我如何检查这个分支到我的本地机器

Everything is already on your local machine, what checkout does is to update the files in your file system to match the state of the commit you are checking out.

一切都已经在您的本地机器上,checkout 所做的是更新文件系统中的文件以匹配您正在检出的提交的状态。

git checkout leafy

updates your files with the content of the commit at the top of the branch (note that if you have uncommited changes in your files, git refuses to checkout. This is done to prevent you from losing changes. You can override this behaviour by adding the -foption). It also sets leafyas your current HEAD, in this case your current HEADdefines which branch you are on.

使用分支顶部的提交内容更新您的文件(请注意,如果您的文件中有未提交的更改,git 拒绝签出。这样做是为了防止您丢失更改。您可以通过添加-f选项)。它还设置leafy为您的 current HEAD,在这种情况下,您的 currentHEAD定义了您所在的分支。

Then to cherry-pick, you need to find out the SHA1 ID of the commits you want to pick (gitk --all&might be handy here). Then use several git cherry-pick <the-interesting-SHA1-ID>in the correct order to cherry-pick the commits.

然后要挑选,您需要找出要挑选的提交的 SHA1 ID(gitk --all&这里可能很方便)。然后git cherry-pick <the-interesting-SHA1-ID>以正确的顺序使用几个来挑选提交。

回答by Greg Hewgill

To switch to the "leafy" branch:

切换到“leafy”分支:

git checkout leafy

To cherry-pick a commit, given its SHA1 identifier:

要挑选一个提交,给定它的 SHA1 标识符:

git cherry-pick abc123

回答by Manohar Reddy Poreddy

Other answers didn't work for me.
Wasted an hour on this.

其他答案对我不起作用。
在这上面浪费了一个小时。

Below sequence worked:

以下序列有效:

First time/ new remote branch:

第一次/新的远程分支:

Get newly created remote repositories list:

获取新创建的远程仓库列表:

Branch -> Checkout
Revision > Tracking Branch >  {select your origin/remote-branch} > Checkout

Switch to your branch:

切换到你的分支:

Branch -> Create
Branch Name > Match Tracking Branch Name
Starting Revision > Tracking Branch >  {select your origin/remote-branch} > Create

Later, once checked out, simply do:

后来,一旦签出,只需执行以下操作:

Branch -> Checkout
Revision > Local Branch >  {select your local-branch} > Checkout

Hope that helps.

希望有帮助。