2013-04-04 89 views
5

我還在苦苦與Git。Git Switch與Checkout在Netbeans

事情是:

我們是一個在項目上工作的兩人。

我創建了一個名爲relation的主分支。

現在我的朋友已經更新了主人,但需要我修復它的一些錯誤。

當我切換到Netbeans分支時,它給了我所有的「關係」 - 改變,並希望我提交它們。

這不是我要找的!

Netbeans的網站告訴我這[切換到分支]:

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 

和[結帳]:

結帳

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 

我從GIT越來越頭疼!

那麼這兩者之間有什麼區別?

我需要某個人能夠切換到[Master]分支,然後更新錯誤,然後切換回我的[Relation]分支,而無需git告訴我在[我]開始時從[Relation]提交更改在[大師]分支

+0

現在更清楚了嗎? – Muqito 2013-04-04 10:49:38

+0

所以,「git switch」不是git操作,那必須是一些Netbeans git術語。 – 2013-04-04 11:15:18

+1

我沒有觸及過netbeans,但是你要找的東西相當於'git stash'和後面的'git checkout'。 Netbeans的交換機似乎試圖在新檢出的分支之上彈出本地更改 - 避免這種情況發生: – 2013-04-04 11:19:03

回答

4

「SWTICH科」和「結帳」之間的區別是,你可以籤什麼性質:

  • 「開關店」:你只檢出一個分支
  • Checkout 「:您簽出任何<tree-ish>參考(即提交,標籤或樹)

雖然仍然relation,您需要:

  • 要麼Add然後commit您當前修改
  • stash您目前未提交修改

然後,有明顯的工作樹,你可以switch branch

Netbeans User Guide on Checkout

注意:如果要將文件切換到已存在的分支(如,以提交,是不是在你的分支之一的頂部),您可以:

  • 使用Team > Git > Branch > Switch To Branch命令,
  • 指定的Switch to Selected Branch對話框中的分支,
  • 檢查出來的一個新的分支(可選),
  • 並按開關。
+0

你是什麼意思的「結帳」:你簽出任何參考(即承諾,標籤或樹)「 – Muqito 2013-04-04 14:39:37

+0

@MaggiQall我的意思是,與」切換到分支「相反,你可以檢出其他引用,而不僅僅是一個分支。你可以簽出一個提交或標籤(你不能這樣做「切換到分支」,在那裏你結帳*只有一個分支)。當然,簽出一個提交或標籤會讓你處於分離頭模式(http://stackoverflow.com/questions/3965676/why-did-git-detach-my-head/3965714#3965714)。所以在你的情況下,「切換到分支」更安全。 – VonC 2013-04-04 14:43:37