Massive Boisson
Massive Boisson

Reputation: 1627

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

Upvotes: 4

Views: 32947

Answers (4)

Manohar Reddy Poreddy
Manohar Reddy Poreddy

Reputation: 27465

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.

Upvotes: 3

Massive Boisson
Massive Boisson

Reputation: 1627

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 .....

Upvotes: 19

Gauthier
Gauthier

Reputation: 41985

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.

Upvotes: 3

Greg Hewgill
Greg Hewgill

Reputation: 993901

To switch to the "leafy" branch:

git checkout leafy

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

git cherry-pick abc123

Upvotes: 0

Related Questions