开发者

git gui branch management

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

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?

Thanks a LOT

--MB


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

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

  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

You are now using the branch.

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


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.

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 -f option). It also sets leafy as your current HEAD, in this case your current HEAD defines which branch you are on.

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.


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.


To switch to the "leafy" branch:

git checkout leafy

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

git cherry-pick abc123
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜