2012-07-18 49 views
17

我手動審查變化的一個巨大的數字(在1000)和替換腳本對一些消息目錄。目前,我正在做git add -p,但我一直在休息片刻,以檢查其他文件或調整劇本,所以我交流與git checkout -p放棄我不想改變。有沒有辦法將兩者結合起來?即對於每個人來說,我都希望選擇放棄它,或放棄它。同時添加的git通過搜索由-p和git結帳-p

+0

我有同樣的問題。使用'git add -p'選擇我想要的第一次提交中的某些區塊。切換到'git checkout -p'丟棄一些。添加更多。提交併添加剩下的所有內容以進行第二次提交。結合添加和結帳將會很棒! – Tieme 2016-01-13 15:58:41

回答

-1

階段你所需要的,提交,然後復位或藏匿清潔工作目錄來擺脫你不需要的東西。

4

如果您使用的是Windows或Mac OS,則可以使用免費的SourceTree GUI應用程序,該應用程序允許您在差異視圖中放映或放棄每個大塊(或甚至從每個大塊中選擇線)。

Stage/Discard hunk

+0

是的,這將是解決方法。我正在尋找一個cli解決方案。布感謝:) – Tieme 2016-01-20 09:41:41

0

怎麼樣在你不想的階段, 帥哥畢竟這些打字j - leave this hunk undecided, see next undecided hunk,運行git checkout --,然後選擇那些帥哥即將上演,和其他丟棄。

當您使用 git add -p

,打字?將顯示幫助

Stage this hunk [y,n,q,a,d,/,e,?]? 
y - stage this hunk 
n - do not stage this hunk 
q - quit, do not stage this hunk nor any of the remaining ones 
a - stage this and all the remaining hunks in the file 
d - do not stage this hunk nor any of the remaining hunks in the file 
g - select a hunk to go to 
/- search for a hunk matching the given regex 
j - leave this hunk undecided, see next undecided hunk 
J - leave this hunk undecided, see next hunk 
k - leave this hunk undecided, see previous undecided hunk 
K - leave this hunk undecided, see previous hunk 
s - split the current hunk into smaller hunks 
e - manually edit the current hunk 
? - print help 
+0

總是使用'j'爲所有你不想要階段的人會讓你在一個循環...你可以使用'n'因爲你不想階段,然後'git結賬 - 事後確實......但這不適用於我在問題底下的評論中描述的情況。 – Tieme 2016-01-21 08:36:18

0

你吃過看看混帳GUI。這是一個與git捆綁在一起的實用程序,並且試圖簡化複雜的操作,這些操作是分級和結帳的混合。你可以閱讀一下here

您可以選擇階段性大塊和放棄更改的其餘部分。通過這樣做ctrl + jcmd + j您可以檢出選定的文件。

我知道從shell使用git要快得多,但在像這樣的複雜情況下,在不同命令之間切換會變成開銷。