Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Switch vs Checkout in Netbeans

Tags:

git

I'm still struggling with Git.

The thing is:

We're a two persons working on a project.

I created a new branch out of master called relation.

Now my friend have updated master but needs me to fix some bugs on it.

When I do a switch to branch in Netbeans it gives me all my "relation"-changes and wants me to commit them.

That's not what I'm looking for!

Netbeans site tells me this [Switch to branch]:

Switch to Branch
Actor: User

Action: User wants to switch to a branch (see also Checkout)

"Priority:" 1

Scenario:

User selects a versioned context and invokes 'switch branch' from the main menu
User specifies the branch and additional options - keep local changes etc.
The working tree is switched to the specified branch

and [Checkout]:

Checkout

Actor: User

Action: User wants to checkout a specific revision/tag/branch

"Priority:" 1

Scenario:

User selects a a versioned context and invokes 'chekout' from the main menu
User specifies the revision/tag/branch to checkout
The working tree will be switched to the specified revision

I'm getting a headache from GIT!

So what's the difference between theese two?

I need to someone be able to switch to the [Master] branch and then update the bugs, and then switch back to my [Relation] branch without git telling me to commit changes from [Relation] when I'm on the [Master] branch

like image 581
Muqito Avatar asked Apr 04 '13 10:04

Muqito


1 Answers

The difference between "Swtich Branch" and "Checkout" is the nature of what you can checkout:

  • "Switch Branch": you checkout only a branch
  • "Checkout": you checkout any <tree-ish> reference (i.e. commit, tag or tree)

While still on relation, you need to:

  • either Add then commit your current modification
  • or stash your current non-committed modification

Then, with a clear working tree, you can switch branch.

See the Netbeans User Guide on Checkout

Note: If you want to switch your files to a branch that already exists (e.g., to a commit that is not at the top of one of your branches), you can:

  • use the Team > Git > Branch > Switch To Branch command,
  • specify the branch in the Switch to Selected Branch dialog box,
  • check it out as a new branch (optionally),
  • and press Switch.
like image 144
VonC Avatar answered Oct 27 '22 01:10

VonC