Diferencia entre revisiones de «Git para Administradores»

De MoodleDocs
m (added Git para Mac)
m (tidy up)
Línea 1: Línea 1:
{{EnTraduccion}}
{{EPendiente de traducir}}
{{Instalación}}
{{Instalación}}
Esta página describe como mantener una copia de Moodle en su servidor de producción, que pueda ser actualizada fácilmente usando Git. Si Usted tiene personalizaciones del código del núcleo (core) de Moodle, se le recomienda que siga las instrucciones en [https://docs.moodle.org/dev/Quick_Git_start_guide_for_Moodle_development Quick Git start guide for Moodle development]].
Esta página describe como mantener una copia de Moodle en su servidor de producción, que pueda ser actualizada fácilmente usando Git. Si Usted tiene personalizaciones del código del núcleo (core) de Moodle, se le recomienda que siga las instrucciones en [https://docs.moodle.org/dev/Quick_Git_start_guide_for_Moodle_development Quick Git start guide for Moodle development]].
Línea 83: Línea 83:
Did you intend to checkout 'origin/MOODLE_25_STABLE' which can not be resolved as commit?
Did you intend to checkout 'origin/MOODLE_25_STABLE' which can not be resolved as commit?
</pre>
</pre>
In this case you should ask the Mantainer, here Petr Škoda, if ''master'' is the correct branch for Moodle 2.5+ and he will reply that the [[Book module]] has been already integrated in Moodle starting from 2.3 so there's no need to install it usit ''git''. Please, as a general rule, before asking the Mantainer for something you should check the online documentation.
In this case you should ask the Mantainer, here Petr Škoda, if ''master'' is the correct branch for Moodle 2.5+ and he will reply that the [[Libro]] has been already integrated in Moodle starting from 2.3 so there's no need to install it usit ''git''. Please, as a general rule, before asking the Mantainer for something you should check the online documentation.


Now it is wise to put the new directory mod/book/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.
Now it is wise to put the new directory mod/book/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.

Revisión del 18:34 22 oct 2013

Plantilla:EPendiente de traducir

Esta página describe como mantener una copia de Moodle en su servidor de producción, que pueda ser actualizada fácilmente usando Git. Si Usted tiene personalizaciones del código del núcleo (core) de Moodle, se le recomienda que siga las instrucciones en Quick Git start guide for Moodle development].

Para obtener el mayor provecho de Git, vale la pena el esfuerzo para entender sus conceptos básicos - vea también la sección inferior. La curva de aprendizaje puede ser difícil, especialmente si Usted está acostumbrado a usar CVS o Subversion.

Obtención de Git (Windows, OSX, Linux y otros)

El soporte para Git estaba, hasta hace muy poco tiempo, principalmente confinado a Linux, pero actualmente hay archivos para los sistemas operativos más populares:

Una vez que haya descargado e instalado el Git relevante para su sistema operativo, las instrucciones (comandos) git de éste documento deberían de trabajar con su sistema operativo.

Obtención del código de Git

Aquí se discute la versión de Git para línea de comando. Los clientes gráficos son poco menos que envoltorios alrededor de la versión para línea de comando, por lo que Usted debería de poder deducir los parámetros correctos muy fácilmente.

Usted puede encontrar el repositorio Git oficial de Moodle en git://git.moodle.org/moodle.git (con una clona oficial en git://github.com/moodle/moodle.git). Para inicializar su checkout local, use

$ git clone git://git.moodle.org/moodle.git                       (1)
$ cd moodle
$ git branch -a                                                   (2)
$ git branch --track MOODLE_25_STABLE origin/MOODLE_25_STABLE     (3)
$ git checkout MOODLE_25_STABLE                                   (4)
  • El comando (1) inicializa el nuevo repositorio local como una clona del repositorio (ascendente) upstream (basado en el servidor remoto) moodle.git . El repositorio ascendente upstream se llama por defecto origin. Se crea un nuevo directorio llamado moodle, en donde se descargan todos los archivos. Esta operación puede demorar bastante, porque de hecho está obteniendo toda la historia completa de todas las versiones de Moodle
  • El comando (2) enlista todas las ramas disponibles.
  • Use el comando (3) para crear una nueva rama local llamada MOODLE_25_STABLE y configurarla para que rastree la rama remota MOODLE_25_STABLE del repositorio ascendente upstream.
  • El comando (4) de hecho, cambia hacia la rama local recientemente creada.

Tome nota de que Git tiene muchas opciones para cada comando y que de hecho es posible hacer todo el proceso de arriba con un sólo comando (¡¡¡se les queda de tarea!!!).

Git desde atrás de un firewall

Git usa un protocolo de solo-lectura que puede ser bloqueado por su firewall (port 9418). Si ésto fuera problema, Usted pued eusar la versión HTTP de Github https://github.com/moodle/moodle.git. Es lenta, por lo que se le recomienda que mejor use el protocolo Git si puede hacerlo.

Actualización de su instalación

El equipo de desarrolladores de Moodle realiza la integración y prueba de problemas resueltos los días Lunes y Martes. El miércoles, Usted puede instalar todos los parches al actualizar su código. Revise shortlog para ver si el repositorio oficial ya ha sido actualizado o no.

Para actualizar su código a la versión más reciente (en la rama MOODLE_25_STABLE) todo lo que tiene que hacer es:

$ cd /path/to/your/moodle/
$ git pull

Si éste es un sitio de producción Usted debería de considerar las instrucciones acerca de la Actualización_de_moodle, como por ejemplo, hacer respaldos.

Instalar un complemento desde el repositorio Git

¡¡¡ Ésta es una opción avanzada, no se la recomendamos !!! This is one way to handle adding plugins from other Git repositories into your Moodle repository. Another way is to use Git Submodules. However, at the time of writing, this is one of Git's rougher features and should be regarded as an advanced option.

FPor ejemplo, digamos que queremos instalar el módulo de Libro desde su repositorio Git hacia nuestro Moodle 2.5.

$ cd /path/to/your/moodle/
$ cd mod                                                          (1)
$ git clone git://github.com/skodak/moodle-mod_book.git book      (2)
$ cd book
$ git checkout -b MOODLE_25_STABLE origin/MOODLE_25_STABLE        (3)
$ git branch -d master                                            (4)

The command (1) changes the current directory into the mod folder of your local Moodle clone. The command (2) creates a new subdirectory book and makes a local clone of Petr Škoda's vanilla Book repository. The command (3) creates a new local branch that will track the remote branch with a Book version for Moodle 2.2. The command (4) deletes the master that was created automatically by git-clone in (2) as we do not want it in this production checkout.

Note: you should check first the compatibility of a module with your Moodle branch by asking directly to the Maintainer before cloning the repo or - if you want to guess it - by issueing the command below before running the command (3), in order to verify what is available among the branches:

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/MOODLE_15_STABLE
  remotes/origin/MOODLE_17_STABLE
  remotes/origin/MOODLE_18_STABLE
  remotes/origin/MOODLE_19_STABLE
  remotes/origin/MOODLE_20_STABLE
  remotes/origin/MOODLE_21_STABLE
  remotes/origin/MOODLE_22_STABLE
  remotes/origin/master

This will avoid an error message when you issue the command (3) against a nonexistent branch, e.g.:

§ git checkout -b MOODLE_25_STABLE origin/MOODLE_25_STABLE
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'origin/MOODLE_25_STABLE' which can not be resolved as commit?

In this case you should ask the Mantainer, here Petr Škoda, if master is the correct branch for Moodle 2.5+ and he will reply that the Libro has been already integrated in Moodle starting from 2.3 so there's no need to install it usit git. Please, as a general rule, before asking the Mantainer for something you should check the online documentation.

Now it is wise to put the new directory mod/book/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.

$ cd /path/to/your/moodle/
$ echo /mod/book/ >> .git/info/exclude

To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.

$ cd /path/to/your/moodle/
$ git pull
$ cd mod/book
$ git pull

Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.

Vea también

Moodle Docs
Moodle forum discussions
Recursos externos


Vea Git for administrators