Некоторые опции в интерактивном режиме не работают на git

Я просто пробую интерактивный режим с проверкой фиксации

git checkout -p <commit_sha1>

Доступны различные варианты

Применить этот фрагмент к индексу и рабочему дереву [y,n,q,a,d,/,s,e,?]?

и нажатие ? показывает еще больше вариантов

y - apply this hunk to index and worktree
n - do not apply this hunk to index and worktree
q - quit; do not apply this hunk nor any of the remaining ones
a - apply this hunk and all later hunks in the file
d - do not apply this hunk nor any of the later 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/J/k/K или s, он всегда возвращается к тому же файлу и снова запрашивает выбор.

В то время как все остальные (y/n/q/a/d/.. и т. д.) работают.

Есть ли причина для этого?


person Kamafeather    schedule 02.10.2014    source источник
comment
Если вам не нравятся графические интерфейсы, я рекомендую git gui. Вы можете очень быстро выбирать строки и добавлять/удалять их в/из индекса.   -  person musiKk    schedule 02.10.2014
comment
@musiKk Я ищу более дружелюбный способ работы, и мне не нравятся графические интерфейсы. К сожалению, моя версия git — 1.7.x на моих компьютерах для разработки и производства, и я не могу ее обновить. В любом случае спасибо за хорошее предложение!   -  person Kamafeather    schedule 02.10.2014
comment
Я понимаю. Он включен в версию для Windows, но, по крайней мере, в Ubuntu это другой пакет.   -  person musiKk    schedule 02.10.2014


Ответы (1)


Apply this hunk to index and worktree [y,n,q,a,d,/,s,e,?]?

git дает вам только выбор y,n,q,a,d,/,s,e,?, потому что снимок файла имеет только 1 фрагмент. Справка распечатывает все варианты, которые могут быть доступны, но в вашем случае у вас нет возможности пропустить фрагмент.

Кусок — это одно отличие в файле. Итак, git хочет вам сказать, что в этом файле есть только один diff. Таким образом, вы не можете пропустить его и перейти к следующему.

Например... если я создам текстовый файл и помещу в него ваш вопрос, чтобы получить этот diff

@@ -1,9 +1,28 @@
 I'm just trying the interactive mode with a commit checkout

+    git checkout -p <commit_sha1>
+
 There are different choices available

+    Apply this hunk to index and worktree [y,n,q,a,d,/,s,e,?]?
+
 and pressing ? it shows even more options

+    y - apply this hunk to index and worktree
+    n - do not apply this hunk to index and worktree
+    q - quit; do not apply this hunk nor any of the remaining ones
+    a - apply this hunk and all later hunks in the file
+    d - do not apply this hunk nor any of the later 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
+
 I actually tried all the relatives to undecided hunks, and none of them seem to work. After the choice, no matter if I press j/J/k/K or s it always returns to the same file and as
k again for a choice.

 While all the others (y/n/q/a/d/.. etc.) work.

Тогда интерактивная касса позволила бы мне разделить фактический кусок на более мелкие куски.

Apply this hunk to index and worktree [y,n,q,a,d,/,s,e,?]? s

После этого вы можете выбрать, какой ханк применить, а какой пропустить.

    Split into 3 hunks.
@@ -1,4 +1,6 @@
 I'm just trying the interactive mode with a commit checkout

+    git checkout -p <commit_sha1>
+
 There are different choices available

Apply this hunk to index and worktree [y,n,q,a,d,/,j,J,g,e,?]? j

Пропустите (j) и перейдите к следующему фрагменту.

@@ -3,4 +5,6 @@
 There are different choices available

+    Apply this hunk to index and worktree [y,n,q,a,d,/,s,e,?]?
+
 and pressing ? it shows even more options

Apply this hunk to index and worktree [y,n,q,a,d,/,k,K,j,J,g,e,?]?
person René Link    schedule 02.10.2014
comment
Ты прав! Я не думал об этом. Я предположил, что неопределенные куски были связаны со всем взаимодействием, а не только с одним текущим файлом. Спасибо. Хороший ответ. - person Kamafeather; 02.10.2014