Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions book/07-git-tools/sections/interactive-staging.asc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[[_interactive_staging]]
=== Interactive Staging
=== Organización interactiva

Git comes with a couple of scripts that make some command-line tasks easier.
Here, you’ll look at a few interactive commands that can help you easily craft your commits to include only certain combinations and parts of files.
These tools are very helpful if you modify a bunch of files and then decide that you want those changes to be in several focused commits rather than one big messy commit.
This way, you can make sure your commits are logically separate changesets and can be easily reviewed by the developers working with you.
If you run `git add` with the `-i` or `--interactive` option, Git goes into an interactive shell mode, displaying something like this:
El git viene con unos cuantos scripts que hace que algunas líneas de comando sean más fáciles de usar.
Aquí, Veras unos cuantos comandos interactivos que te ayudaran a preparar tus confirmaciones para incluir solo ciertas combinaciones y partes de los archivos.
Estás herramientas serán muy útiles si modificas unos cunatos archivos y decides que quieres esos cambios estén en varias confirmaciones enfocadas más que en una gran problemática confirmación.
De esta manera, puede asegurarse de que sus confirmaciones sean conjuntos de cambios lógicamente separados y que puedan ser revisados fácilmente por los desarrolladores que trabajan con usted.
Si empiezas `git add` con el `-i` o la opción `--interactive` , Git entra en un modo de celda interactiva, mostrando algo como esto:

[source,console]
----
Expand All @@ -21,15 +21,15 @@ $ git add -i
What now>
----

You can see that this command shows you a much different view of your staging areabasically the same information you get with `git status` but a bit more succinct and informative.
It lists the changes you’ve staged on the left and unstaged changes on the right.
Puedes ver que este comando te muestra una muy diferente vista de tu área de ensayobásicamente la misma informacion que con el with `git status` pero un poco más sucinto e informativo.
Muestra los cambios que haz realizado en la izquierda y cambios que no haz hecho a la derecha.

After this comes a Commands section.
Here you can do a number of things, including staging files, unstaging files, staging parts of files, adding untracked files, and seeing diffs of what has been staged.
Después de esto viene una sección de comandos.
Aquí puedes hacer un sin número de cosas, incluidos los archivos organizados, archivos sin organizar, partes de archivos organizados, agregar archivos sin seguimiento y ver las diferencias de lo que se ha modificado.

==== Staging and Unstaging Files
==== Organizar y desorganziar archivos

If you type `2` or `u` at the `What now>` prompt, the script prompts you for which files you want to stage:
Si tecleas `2` o `u` en el `What now>` rápidamente, la secuencia de comandos le solicita los archivos que desea representar:

[source,console]
----
Expand All @@ -41,7 +41,7 @@ What now> 2
Update>>
----

To stage the TODO and index.html files, you can type the numbers:
Para organizar los archivos de TODO and index.html , puedes teclear los números:

[source,console]
----
Expand All @@ -53,8 +53,8 @@ Update>> 1,2
Update>>
----

The `*` next to each file means the file is selected to be staged.
If you press Enter after typing nothing at the `Update>>` prompt, Git takes anything selected and stages it for you:
El `*` después de cada archivo significa que el archivo fue seleccionado para ser organizado.
Si presionas Enter después de no escribir nada en el `Update>>` rapidamente, Git toma cualquier cosa seleccionada y la organiza por ti:

[source,console]
----
Expand All @@ -71,7 +71,7 @@ What now> 1
3: unchanged +5/-1 lib/simplegit.rb
----

Now you can see that the TODO and index.html files are staged and the simplegit.rb file is still unstaged.
Ahora puedes ver que los archivos de TODO and index.html han sido organizados y el archivo simplegit.rb aun está sin organizar.
If you want to unstage the TODO file at this point, you use the `3` or `r` (for revert) option:

[source,console]
Expand All @@ -93,7 +93,7 @@ Revert>> [enter]
reverted one path
----

Looking at your Git status again, you can see that you’ve unstaged the TODO file:
Mirando el estatus de tu Git de nuevo, puedes ver que haz desordenado el archivo de TODO:

[source,console]
----
Expand All @@ -107,9 +107,9 @@ What now> 1
3: unchanged +5/-1 lib/simplegit.rb
----

To see the diff of what you’ve staged, you can use the `6` or `d` (for diff) command.
It shows you a list of your staged files, and you can select the ones for which you would like to see the staged diff.
This is much like specifying `git diff --cached` on the command line:
Para ver la diferencia de lo que ya haz ordenado, puedes usar el `6` o `d` (para diferente) comando.
Este te muestra una lista de tus archivos organziados, y puedes seleccionar aquellos que quisieras ver la diferencia de su organización.
Esto es como especificar el `git diff --cached` en la línea de comando:

[source,console]
----
Expand All @@ -134,14 +134,14 @@ index 4d07108..4335f49 100644
<script type="text/javascript">
----

With these basic commands, you can use the interactive add mode to deal with your staging area a little more easily.
Con estos comandos básicos,puedes usar el modo de añadir interactivo para tratar con su área de organización un poco más fácilmente.

==== Staging Patches
==== Parches de organización

It’s also possible for Git to stage certain parts of files and not the rest.
For example, if you make two changes to your simplegit.rb file and want to stage one of them and not the other, doing so is very easy in Git.
From the interactive prompt, type `5` or `p` (for patch).
Git will ask you which files you would like to partially stage; then, for each section of the selected files, it will display hunks of the file diff and ask if you would like to stage them, one by one:
De igual manera es posible para el Git el organizar ciertas partes de archivos y no todos los demás.
Por ejemplo, Si haces dos simples cambios en tu archivo simplegit.rb y quieres organizar uno pero no el otro, hacer esto es muy fácil en Git.
Desde el prompt interactivo, teclea `5` o `p` (para parche).
Git te preguntará que archivos quieres organizar parcialmente; entonces, para cada sección de los archivos seleccionados, mostrará bloques del archivo diferencial y te preguntará si quisierás organizarlos, uno por uno:

[source,console]
----
Expand All @@ -161,8 +161,8 @@ index dd5ecc4..57399e0 100644
Stage this hunk [y,n,a,d,/,j,J,g,e,?]?
----

You have a lot of options at this point.
Typing `?` shows a list of what you can do:
Tienes muchas opciones en este punto.
Teclear `?` te mostrará una lista de lo que puedes hacer:

[source,console]
----
Expand All @@ -182,8 +182,8 @@ e - manually edit the current hunk
? - print help
----

Generally, you’ll type `y` or `n` if you want to stage each hunk, but staging all of them in certain files or skipping a hunk decision until later can be helpful too.
If you stage one part of the file and leave another part unstaged, your status output will look like this:
Generalmente, teclearías `y` o `n` Si quisieras organizar cada bloque, pero organizar cada uno de ellos en ciertos archivos o saltarte una decisión para algún bloque puede ser de ayuda para más tarde también.
Si organizas una parte del archivo y dejas la otra partida sin organizar, su salida de estado se verá así:

[source,console]
----
Expand All @@ -194,11 +194,11 @@ What now> 1
3: +1/-1 +4/-0 lib/simplegit.rb
----

The status of the simplegit.rb file is interesting.
It shows you that a couple of lines are staged and a couple are unstaged.
You’ve partially staged this file.
At this point, you can exit the interactive adding script and run `git commit` to commit the partially staged files.
El estatus del archivo simplegit.rb es interesante.
Te muestra que un par de líneas están organizadas y otro par está desorganizado.
Has organizado parcialmente este archivo.
En este punto, puede salir del script de adición interactivo y ejecutar `git commit` para confirmar los archivos parcialmente organiazdos.

You also don’t need to be in interactive add mode to do the partial-file staging – you can start the same script by using `git add -p` or `git add --patch` on the command line.
De igual manera no necesitas estar en el modo de adición interactivo para hacer el parcial - organización de archivos – Puedes iniciar el mismo script usando `git add -p` o `git add --patch` en la línea de comando.

Furthermore, you can use patch mode for partially resetting files with the `reset --patch` command, for checking out parts of files with the `checkout --patch` command and for stashing parts of files with the `stash save --patch` command. We'll go into more details on each of these as we get to more advanced usages of these commands.
Además, puede usar el modo de parche para restablecer parcialmente los archivos con el comando `reset --patch` , para verificar partes de archivos con el comando `checkout --patch` y para esconder partes de archivos con el comando `stash save --patch`. Vamos a entrar en más detalles sobre cada uno de estos a medida que accedemos a usos más avanzados de estos comandos.