7

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

Muqito
  • 1,369
  • 3
  • 13
  • 27

1 Answers1

7

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.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • What do you mean by ""Checkout": you checkout any reference (i.e. commit, tag or tree)" – Muqito Apr 04 '13 at 14:39
  • @MaggiQall I mean that, contrary to "Switch to Branch", you can checkout other references than just a branch. You can checkout a commit or a tag (which you cannot do with "Switch to Branch", where you checkout *only* a branch). Of course, checkout a commit or a tag would leave you in a DETACHED HEAD mode (http://stackoverflow.com/questions/3965676/why-did-git-detach-my-head/3965714#3965714). So in your case, "Switch to Branch" is safer. – VonC Apr 04 '13 at 14:43