我手動審查變化的一個巨大的數字(在1000)和替換腳本對一些消息目錄。目前,我正在做git add -p
,但我一直在休息片刻,以檢查其他文件或調整劇本,所以我交流與git checkout -p
放棄我不想改變。有沒有辦法將兩者結合起來?即對於每個人來說,我都希望選擇放棄它,或放棄它。同時添加的git通過搜索由-p和git結帳-p
回答
階段你所需要的,提交,然後復位或藏匿清潔工作目錄來擺脫你不需要的東西。
如果您使用的是Windows或Mac OS,則可以使用免費的SourceTree GUI應用程序,該應用程序允許您在差異視圖中放映或放棄每個大塊(或甚至從每個大塊中選擇線)。
是的,這將是解決方法。我正在尋找一個cli解決方案。布感謝:) – Tieme 2016-01-20 09:41:41
怎麼樣在你不想的階段, 帥哥畢竟這些打字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
總是使用'j'爲所有你不想要階段的人會讓你在一個循環...你可以使用'n'因爲你不想階段,然後'git結賬 - 事後確實......但這不適用於我在問題底下的評論中描述的情況。 – Tieme 2016-01-21 08:36:18
你吃過看看混帳GUI。這是一個與git捆綁在一起的實用程序,並且試圖簡化複雜的操作,這些操作是分級和結帳的混合。你可以閱讀一下here
您可以選擇階段性大塊和放棄更改的其餘部分。通過這樣做ctrl + j
或cmd + j
您可以檢出選定的文件。
我知道從shell使用git要快得多,但在像這樣的複雜情況下,在不同命令之間切換會變成開銷。
- 1. Git和添加-p問題
- 2. Git的添加-p不適用編輯
- 3. Git format-patch vs git log -p
- 4. git的添加-p在Windows的Git外殼,child_info_fork ::中止
- 5. 理解git的補丁命令(GIT添加-p)
- 6. git stash保存-u和-p
- 7. git log -p vs git show vs git diff
- 8. 混帳時通過2.7.4</p> <p>特定機器
- 9. 更好的git add -p?
- 10. git add的相反-p
- 11. Git通過grep/regex添加行索引
- 12. 的git - 結帳2個項目同時
- 13. 重映射git的結帳git的結帳b或git的結帳
- 14. Git add -p但新文件
- 15. Git相當於RCS co -p?
- 16. hg相當於git add -p?
- 17. 從ruby運行`git add -p`
- 18. git結帳。添加稀疏結帳排除的目錄
- 19. GIT中是否有一個命令可以選擇「git add -p」和「git checkout -p」組合?
- 20. Jenkins和Git稀疏結帳
- 21. 廚師和git結帳
- 22. 更新由</p> <p>通過
- 23. Git結帳差異git結帳來源/ <branch-name>和git結帳<branch-name>?
- 24. 沒有裝飾的Git diff/log -p
- 25. 水暖等同於`git的結帳 - .`
- 26. P/L SQL搜索查詢
- 27. 搜索並替換「-p」
- 28. 添加<p></p>在HTML
- 29. 搜索與多個搜索條件的李在列表</p> <p>
- 30. Visual Studio代碼:'Ctrl + P'缺少git?
我有同樣的問題。使用'git add -p'選擇我想要的第一次提交中的某些區塊。切換到'git checkout -p'丟棄一些。添加更多。提交併添加剩下的所有內容以進行第二次提交。結合添加和結帳將會很棒! – Tieme 2016-01-13 15:58:41