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
56 changes: 28 additions & 28 deletions book/07-git-tools/sections/submodules.asc
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ index 6fc0b3d..fd1cc29 100644
> better connection routine
----

This is pretty cool as we can actually see the log of commits that we're about to commit to in our submodule. Once committed, you can see this information after the fact as well when you run `git log -p`.
Esto está muy bien como podemos ver realmente el log de los commits a los que estamos a punto de hacer commit en nuestro submódulo. Una vez hecho el commit, usted puede ver esta información después del hecho también cuando usted ejecuta `git log -p`.

[source,console]
----
Expand All @@ -350,27 +350,27 @@ Submodule DbConnector c3f01dc..c87d55d:
> better connection routine
----

Git will by default try to update **all** of your submodules when you run `git submodule update --remote` so if you have a lot of them, you may want to pass the name of just the submodule you want to try to update.
Git intentará por defecto actualizar **all** sus submódulos cuando ejecute `git submodule update --remote` así que si usted tiene muchos de ellos, puede que quiera poner el nombre solamente del submódulo que usted quiera intentar actualizar.

===== Working on a Submodule
===== Trabajando en un submódulo

It's quite likely that if you're using submodules, you're doing so because you really want to work on the code in the submodule at the same time as you're working on the code in the main project (or across several submodules). Otherwise you would probably instead be using a simpler dependency management system (such as Maven or Rubygems).
Es muy probable que si usted está usando submódulos, lo está haciendo porque de verdad quiere trabajar en el código en el submódulo al mismo tiempo que está trabajando en el código en el proyecto principal (o a través de varios submóduos). Si no, usted, probablemente, en su lugar, estaría usando un sistema de administración de dependencias más simple (tal como Maven o Rubygems).

So now let's go through an example of making changes to the submodule at the same time as the main project and committing and publishing those changes at the same time.
Y ahora veamos un ejemplo de hacer cambios a un submódulo al mismo tiempo que al proyecto principal y haciendo commit y aplicando esos cambios al mismo tiempo.

So far, when we've run the `git submodule update` command to fetch changes from the submodule repositories, Git would get the changes and update the files in the subdirectory but will leave the sub-repository in what's called a ``detached HEAD'' state. This means that there is no local working branch (like ``master'', for example) tracking changes. So any changes you make aren't being tracked well.
Hasta aquí, cuando ejecutábamos el comando `git submodule update` para traer cambios desde los repertorios de submódulos, Git obtendría los cambios y actualizaría los archivos en el subdirectorio, pero dejaría el sub-repositorio en lo que se llama un estado ``detached HEAD''. Esto significa que no hay una rama de trabajo local (como ``master'', por ejemplo) rastreando los cambios. Así que cualquier cambio que usted esté haciendo no está siendo rastreado tampoco.

In order to set up your submodule to be easier to go in and hack on, you need do two things. You need to go into each submodule and check out a branch to work on. Then you need to tell Git what to do if you have made changes and then `git submodule update --remote` pulls in new work from upstream. The options are that you can merge them into your local work, or you can try to rebase your local work on top of the new changes.
Con el fin de configurar su submódulo para que sea más fácil de entrar y piratear, usted necesita hacer dos cosas. Necesita ir a cada submódulo e ir a una rama para trabajar. Luego necesita decirle a Git qué hacer si usted ha hecho cambios y después `git submodule update --remote` aplica nuevo trabajo de upstream. Las opciones son que usted puede unirlas en su trabajo local, o puede intentar hacer rebase a su trabajo local en lo más alto de los nuevos cambios.

First of all, let's go into our submodule directory and check out a branch.
Primero que nada, entremos en nuestro directorio de submódulos y vamos a una rama.

[source,console]
----
$ git checkout stable
Switched to branch 'stable'
----

Let's try it with the ``merge'' option. To specify it manually, we can just add the `--merge` option to our `update` call. Here we'll see that there was a change on the server for this submodule and it gets merged in.
Intentémoslo con la opción ``merge''. Para especificarlo manualmente, podemos añadir la opción `--merge` a nuestra solicitud `update`. Aquí veremos que hubo un cambio en el servidor para este submódulo y que este se fusiona.

[source,console]
----
Expand All @@ -388,7 +388,7 @@ Fast-forward
Submodule path 'DbConnector': merged in '92c7337b30ef9e0893e758dac2459d07362ab5ea'
----

If we go into the DbConnector directory, we have the new changes already merged into our local `stable` branch. Now let's see what happens when we make our own local change to the library and someone else pushes another change upstream at the same time.
Si vamos al directorio "DbConnector", tenemos los nuevos cambios ya fusionados en nuestra rama local `stable`. Ahora veamos qué pasa cuando hacemos nuestro propio cambio local a la biblioteca y alguien más pone otro cambio upstream al mismo tiempo.

[source,console]
----
Expand All @@ -399,7 +399,7 @@ $ git commit -am 'unicode support'
1 file changed, 1 insertion(+)
----

Now if we update our submodule we can see what happens when we have made a local change and upstream also has a change we need to incorporate.
Ahora, si actualizamos nuestro submódulo, podemos ver qué pasa cuando hemos hecho un cambio local y un upstream también tiene un cambio que necesitamos incorporar.

[source,console]
----
Expand All @@ -409,17 +409,17 @@ Applying: unicode support
Submodule path 'DbConnector': rebased into '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94'
----

If you forget the `--rebase` or `--merge`, Git will just update the submodule to whatever is on the server and reset your project to a detached HEAD state.
Si olvidas el `--rebase` o el `--merge`, Git actualizará el submódulo a lo que sea que esté en el servidor y reiniciará su proyecto a un estado HEAD desconectado.

[source,console]
----
$ git submodule update --remote
Submodule path 'DbConnector': checked out '5d60ef9bbebf5a0c1c1050f242ceeb54ad58da94'
----

If this happens, don't worry, you can simply go back into the directory and check out your branch again (which will still contain your work) and merge or rebase `origin/stable` (or whatever remote branch you want) manually.
Si esto pasa, no se preocupe, usted puede simplemente regresar al directorio e ir a su rama de nuevo (la cual aún contendrá su trabajo) y unir o hacer rebase `origin/stable` (o cualquier rama remota que quiera) manualmente.

If you haven't committed your changes in your submodule and you run a submodule update that would cause issues, Git will fetch the changes but not overwrite unsaved work in your submodule directory.
Si no ha hecho commit a sus cambios en su submódulo y ejecuta una actualización de submódulo que podría causar problemas, Git buscará los cambios, pero no sobrescribirá el trabajo no guardado en su directorio de submódulos.

[source,console]
----
Expand All @@ -437,7 +437,7 @@ Aborting
Unable to checkout 'c75e92a2b3855c9e5b66f915308390d9db204aca' in submodule path 'DbConnector'
----

If you made changes that conflict with something changed upstream, Git will let you know when you run the update.
Si usted hizo cambios que hagan conflicto con algo cambiado en upstream, Git se lo hará saber cuando usted ejecute la actualización.

[source,console]
----
Expand All @@ -449,12 +449,12 @@ Automatic merge failed; fix conflicts and then commit the result.
Unable to merge 'c75e92a2b3855c9e5b66f915308390d9db204aca' in submodule path 'DbConnector'
----

You can go into the submodule directory and fix the conflict just as you normally would.
Usted puede ir al directorio de submódulos y arrglar el conflicto como lo haría normalmente.

[[_publishing_submodules]]
===== Publishing Submodule Changes

Now we have some changes in our submodule directory. Some of these were brought in from upstream by our updates and others were made locally and aren't available to anyone else yet as we haven't pushed them yet.
Ahora tenemos algunos cambios en nuestro directorio de submódulos. Algunos de estos fueron traídos mediante upstream por nuestras actualizaciones y otros fueron hechos localmente y no están disponibles para nadie aún, ya que no los hemos aplicado todavía.

[source,console]
----
Expand All @@ -467,9 +467,9 @@ Submodule DbConnector c87d55d..82d2ad3:
> add new option for conn pooling
----

If we commit in the main project and push it up without pushing the submodule changes up as well, other people who try to check out our changes are going to be in trouble since they will have no way to get the submodule changes that are depended on. Those changes will only exist on our local copy.
Si hacemos commit en el proyecto principal y lo subimos sin subir los cambios de submódulos también, las otras personas que intenten verificar nuestros cambios van a tener problemas ya que no tendrán forma de obtener los cambios de submódulos que que son necesarios. Estos cambios solo existirán en nuestra copia local.

In order to make sure this doesn't happen, you can ask Git to check that all your submodules have been pushed properly before pushing the main project. The `git push` command takes the `--recurse-submodules` argument which can be set to either ``check'' or ``on-demand''. The ``check'' option will make `push` simply fail if any of the committed submodule changes haven't been pushed.
Con el fin de asegurarnos de que esto no ocurra, usted puede pedirle a Git que revise que todos los submódulos han sido aplicados correctamente antes de aplicar el proyecto principal. El comando `git push` toma el argumento `--recurse-submodules` el cual puede estar listo para ``check'' o ``on-demand''. La opción ``check'' hará simplemente fallar a `push` si alguno de los cambios de los submódulos en commit no han sido aplicados.

[source,console]
----
Expand All @@ -489,9 +489,9 @@ or cd to the path and use
to push them to a remote.
----

As you can see, it also gives us some helpful advice on what we might want to do next. The simple option is to go into each submodule and manually push to the remotes to make sure they're externally available and then try this push again.
Como puede ver, también nos da un consejo útil de qué podríamos querer hacer a continuación. La opción simple es ir a cada submódulo y aplicar manualmente a los remotos para asegurarse de que ellos están disponibles externamente y luego intentar este aplique de nuevo.

The other option is to use the ``on-demand'' value, which will try to do this for you.
La otra opción es usar el valor ``on-demand'', el cual intentará hacer esto por usted.

[source,console]
----
Expand All @@ -513,15 +513,15 @@ To https://github.com/chaconinc/MainProject
3d6d338..9a377d1 master -> master
----

As you can see there, Git went into the DbConnector module and pushed it before pushing the main project. If that submodule push fails for some reason, the main project push will also fail.
Como puede ver ahí, Git fue al módulo "DbConnector" y lo aplicó luego de aplicar el proyecto principal. Si el aplicado de ese submódulo falla por alguna razón, el aplicado del proyecto principal también fallará.

===== Merging Submodule Changes
===== Uniendo cambios de submódulo

If you change a submodule reference at the same time as someone else, you may run into some problems. That is, if the submodule histories have diverged and are committed to diverging branches in a superproject, it may take a bit of work for you to fix.
Si usted cambia una referencia de submódulo al mismo tiempo que alguien más, puede que se encuentre con algunos problemas. Esto es, si los historiales de los submódulos han discrepado y están en commit para divergir ramas en un subproyecto, puede que le tome un poco de tiempo arreglarlo.

If one of the commits is a direct ancestor of the other (a fast-forward merge), then Git will simply choose the latter for the merge, so that works fine.
Si alguno de los commit es un predecesor directo del otro (una unión de avance rápido), entonces Git simplemente elegirá el último para la unión, por lo que funciona bien.

Git will not attempt even a trivial merge for you, however. If the submodule commits diverge and need to be merged, you will get something that looks like this:
Git no intentará ni siquiera una unión trivial para usted. Sin embargo, si los commits de los submódulos divergen y necesitan ser unidos, usted tendrá algo parecido a esto:

[source,console]
----
Expand All @@ -539,9 +539,9 @@ CONFLICT (submodule): Merge conflict in DbConnector
Automatic merge failed; fix conflicts and then commit the result.
----

So basically what has happened here is that Git has figured out that the two branches record points in the submodule's history that are divergent and need to be merged. It explains it as ``merge following commits not found'', which is confusing but we'll explain why that is in a bit.
Así que básicamente lo que pasó aquí es que GIT ha entendido que las dos ramas registran puntos en el historial de submódulos que discrepan y necesitan ser unidos. Lo explica como ``merge following commits not found'', lo que es confuso, pero explicaremos por qué eso está en un momento.

To solve the problem, you need to figure out what state the submodule should be in. Strangely, Git doesn't really give you much information to help out here, not even the SHA-1s of the commits of both sides of the history. Fortunately, it's simple to figure out. If you run `git diff` you can get the SHA-1s of the commits recorded in both branches you were trying to merge.
Para resolver el problema, usted encesita entender en qué estado debería estar el submódulo. Extrañamente, Git no le da realmente mucha información ahí para ayudar, ni siquiera el "SHA-1s" de los commits de ambos lados del historial. Afortunadamente, es simplemente para comprender. Si usted ejecuta `git diff`, puede obtener el "SHA-1s" de los commits registrados en las ambas ramas que usted estaba intentando unir.

[source,console]
----
Expand Down