¿Cuáles son las opciones de `git add -p`?

2 minutos de lectura

Avatar de usuario de Hugolpz
Hugolpz

haciendo un git add -p Veo una diferencia y la lista de opciones:

~/workspace$ git add -p                                              
diff --git a/gulpfile.js b/gulpfile.js                                                 
index cf91028..c3a0964 100644                                                          
--- a/gulpfile.js                                                                      
+++ b/gulpfile.js                                                                      
@@ -57,7 +57,7 @@ gulp.task("pack", pack);                                             
 // Minify and concatenate all js libs                                                 
 gulp.task("libs", function() {                                                        
        return gulp.src([                                                              
-               "js/libs/trackjs.js",                                                  
+       //      "js/libs/trackjs.js",  // hidden due to noise but not the bug          
                "js/libs/q.js",                                                        
                "js/libs/jquery.js",                                                   
                "js/libs/cookie.js",                                                   
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]?

Que hace Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? opciones significa? ¿Dónde encontrar sus explicaciones?

  • Gracias. Estaba bloqueando esto.

    – Hugolpz

    30 de diciembre de 2015 a las 10:24

  • Hay un buen video tutorial que explica git add -p aquí: johnkary.net/blog/…. Vale la pena el tiempo.

    – quasoft

    17/10/2016 a las 17:15


si escribes ? en el aviso, obtienes la explicación.

Concretamente las opciones son:

y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or 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

En caso de que experimente la misma confusión que yo, descubrí que a veces el j,J,k,K las opciones no funcionaron, yo pensar (pero no he experimentado lo suficiente como para estar seguro) que solo funcionan dentro del mismo archivo, por lo que puede omitir fragmentos en el mismo archivo, pero no pasar al siguiente archivo y luego volver al anterior.

¿Ha sido útil esta solución?