FAQ Recuperar, actualizar GIT fuentes del proyecto: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 75: Line 75:
[[File:Eclipse php build path.png|240px]]
[[File:Eclipse php build path.png|240px]]


{{ToTranslate}}
=Obtener la última versión de los fuentes usando un acceso completo GIT=
=Get last version of sources using a full GIT access=
== Prerrequisitos ==
== Prerequisite ==
Debe tener una instalación funcional de Eclipse, el plugin '''EGit''' también debe estar instalado.
First you must have a working install of Eclipse. '''EGit''' plugin must also have been installed.
Para instalarlo, use '''Help''' desde el menú Eclipse, seguidamente haga click en '''Install new software''' y click en '''Available software site'''. En la lista de direcciones que aparece, busque el enlace :
For this, use the '''Find And Install process''' into Eclipse menu, add the GIT update URL:  
  http://download.eclipse.org/egit/updates
  http://download.eclipse.org/egit/updates
Then choose to install '''EGit'''.
Seguidamente escoja instalar '''EGit'''.


You must before create an account on GitHub (https://github.com/) and upload a public RSA or DSA certificate into your account profile.
Debe crear antes una cuenta en GitHub (https://github.com/) y subir un certificado público RSA o DSA en su account profile.


Then process is same than getting sources with anonymous access.
El proceso es el mismo que el explicado en la obtención de los fuentes con acceso anónimo.


URL to use for GIT clone is same:
la URL a usar para clonar GIT es la misma:
<source lang="ini">
<source lang="ini">
git@github.com:Dolibarr/dolibarr.git
git@github.com:Dolibarr/dolibarr.git
</source>
</source>


Note that a HTTP URL is also available but it's sometimes offline (so use first one instead):
Tenga en cuenta que también se encuentra disponible una dirección URL HTTP, pero a veces se encuentra fuera de línea:
<source lang="ini">
<source lang="ini">
https://yourgitlogin@github.com/Dolibarr/dolibarr.git
https://yourgitlogin@github.com/Dolibarr/dolibarr.git
</source>
</source>


=Update your repository=
=Actualizar su repositorio=
To update your local workspace, right click on Eclipse project and select "Pull".
Para actualizar su workspace local, haga clic con el botón derecho en el proyecto de Eclipse y seleccione "Pull".


If you made some changes into your Eclipse workspace on files that were changed into the GIT remote reference, your GIT client will make a merge automatically.
Si usted realiza algunos cambios en su workspace de Eclipse, el cliente GIT realizará una fusión automática en los archivos que hayn cambiado en la referencia GIT remoto.
* If there is conflicts, the merge will mark all conflict files as "conflict" (See later to solve this state).
* If not, you will get all new version files including all your changes.


If you already have commited some files into your local repository, your workspace will be marked as "Merged".
* Si se producen conflictos, la fusión marcará todos los archivos con conflictos como "conflict" (Ver más adelante para resolver este estado).
All you have to do is make a commit to validate your local repository as including your changes and changes made by others.
* De lo contrario, recibirá todos los archivos de la nueva versión, incluyendo todos sus cambios.


= Commit and publish your changes =
Si ya ha comiteado algunos archivos en su repositorio local, su workspace se marcará como "Merged".
To see all changes you made into your working directory and waiting to be added into Git:
Todo lo que hay que hacer es crear un commit para validar su repositorio local, incluyendo sus cambios y los cambios realizador por otros.
* With GIT Command Line Interface:
 
= Comitear y publicar sus cambios =
Para ver todos los cambios realizados en su workspace y la espera de ser añadidos en Git:
* Con la línea de comandos GIT:
<source lang="bash">
<source lang="bash">
git status
git status
Line 115: Line 115:
</source>
</source>


To add changes made into your local repository into the GIT index, then commit this index :
Para añadir los cambios realizados en el repositorio local en el índice GIT, confirmar este índice:
* With Eclipse: Right click on file or directory to commit. Select file to add/remove/update into commit.
* Con Eclipse: Clic con el botón derecho del ratón en el archivo o directorio a comitear. Seleccione archivo a añadir/eliminar/actualizar en el comit.
* With GIT Command Line Interface:
* Con la línea de comandos GIT:
<source lang="bash">
<source lang="bash">
git commit -a -m "Commit text"
git commit -a -m "Commit text"
</source>
</source>
This will save add and changes into your local branch.
Esto guardará y añadirá todos los cambios en su rama local.


To push them on the GIT repository server,
Para realizar un push al repositorio GIT del servidor,
* With Eclipse: right click on project and choose "'''Team - Push to Upstream'''".
* Con Eclipse: hacer clic con el botón derecho en el proyecto y elegir "'''Team - Push to Upstream'''".
* With GIT Command Line Interface:
* Con la línea de comandos GIT:
<source lang="bash">
<source lang="bash">
git push
git push
</source>
</source>


To cancel a commit:
Para cancelar un comit:
* With GIT Command Line Interface:
* Con la línea de comandos GIT:
<source lang="bash">
<source lang="bash">
git revert IdCommit  or git revert HEAD  (for last commit)
git revert IdCommit  o git revert HEAD  (para el último comit)
</source>
</source>


= Add an external commit into current repository =
= Añadir un commit externo al repositorio =
Some developers may work and do commit into their own Git repository after forking the project. If you are interesting into getting this changes, you can import them with the following steps with Eclipse:
Algunos desarrolladores pueden trabajar y realizar commits en su repositorio GIT después de haber realizado un fork al proyecto.Si está interesado en conseguir esos cambios, puede importarlos realizando los siguientes pasos en Eclipse:
* First, go into GIT setup view and right click on "'''Remotes'''" of your Eclipse Git working space and choose "'''Create a remote...'''"
* Primero, vaya a la vista GIT setup y haga clic con el botón derecho del ratón en"'''Remotes'''" de su Eclipse Git working space y elija "'''Create a remote...'''"
* Type name or remote fork the developer has create (in most cases, it's developer Git login). For example: "'''thedevlogin'''". Choose also "'''Configure Fetch'''".
* Indique nombre o el fork remoto que el desarrollador ha creado (en la mayoría de los casos, es el GIT login del desarrollador). Por ejemplo: "'''thedevlogin'''". Elija también "'''Configure Fetch'''".
* Type URI of Git repository of developer. For example: '''git://github.com/thedevlogin/dolibarr.git'''. Also add a refspec value to declare the branch you want to get. For example: '''refs/heads/master:refs/remotes/thedevlogin/master'''. Click "'''Save and Fetch'''". A new entry will be added into "Remote Tracking" making possible to read/get commits done into this branch.
* Teclee la URI del respositorio GIT del desarrollador. Por ejemplo: '''git://github.com/thedevlogin/dolibarr.git'''. Añada un valor refspec value para declarar la rama que desea obtener. Por ejemplo: '''refs/heads/master:refs/remotes/thedevlogin/master'''. Clic "'''Save and Fetch'''". Se habrá añadido una nueva entrada en "Remote Tracking" haciendo posible la lectura/obtención de los commits realizados en esa rama.


Now, go on command line of your git repository (in most cases on Linux, it's '''/home/yourlogin/git/yourdolibarr''') and type the git cherry-pick command:
Ahora, ir a la línea de comandos de su repositorio GIT (en la mayoría de casos en Linux, es'''/home/sulogin/git/sudolibarr''') y teclee el comando git cherry-pick:
<source lang="bash">
<source lang="bash">
git cherry-pick -x commitid
git cherry-pick -x commitid
</source>
</source>
where commitid is value of commit id you want to get.
donde el commitid es el valor del commit id que desea obtener.


Once this is done, go back to Eclipse and make a refresh on project. You will see modified files appears with decorators (with conflicts if there is).
Una vez hecho esto, vuelva a Eclipse y haga un refresh sobre el proyecto. Verá los archivos modificados aparecen con decoradores (con conflictos si hay).


=Solving a conflict=
=Solucionar un conflicto=
If a file has been marked as "conflict" after a Pull request, open the file to edit it.
Si un archivo se ha marcado como "conflict" después de un Pull request, ábralo para editarlo.
Find string "<<<<<<<<<<", you will see part of code that is conflict between "<<<<<<<<<" and ">>>>>>>>". Edit manually code lines and remove "<<<<<<<<" and ">>>>>>>".  
Busque el string "<<<<<<<<<<", podrá ver parte del código conflictivo entre "<<<<<<<<<" y ">>>>>>>>". Edite manualmente las líneas de código y elimine "<<<<<<<<" y ">>>>>>>".  


Then, right click on file and select "Add".
Seguidamente haga clic con el botón derecho del ratón en el archivo y seleccione "Add".


If you prefer to forget completely all changes you made into all files (so to restore you workspace with content of remote repository), you can make a hard reset:
Si prefiere perder completamente todos los cambios realizados por usted en todos los archivos (restaurar su workspace con el contenido del repositorio remoto), puede realizar un hard resett:
* With Eclipse, right click on project top line and select "'''Reset'''" then "'''Hard'''" then "'''Reference - HEAD'''".
* Con Eclipse, clic con el botón derecho del ratón sobre el nombre del proyecto y seleccione "'''Reset'''" - "'''Hard'''" - "'''Reference - HEAD'''".
* Using GIT command line tool, you can achieve this with command
* Con la línea de comandos GIT, se puede lograr esto con el comando
<source lang="bash">
<source lang="bash">
git reset --hard HEAD  
git reset --hard HEAD  
</source>
</source>


=Tagging sources=
=Tagging fuentes=
To add a tag to a current version:
Para añadir un tag a la versión actual:
<source lang="bash">
<source lang="bash">
git tag -m "Tag for x.y.z_YYYYMMDD" "x.y.z_YYYYMMDD"
git tag -m "Tag for x.y.z_YYYYMMDD" "x.y.z_YYYYMMDD"
Line 170: Line 170:
</source>
</source>


=Creating a new branch=
=Crear una nueva rama=
This is command used to start a new branch from a clean develop cloned repository:
Este es el comando a usar para crear una nueva rams desde un repositorio clonado de desarrollo:
<source lang="bash">
<source lang="bash">
git branch x.y
git branch x.y
Line 177: Line 177:
</source>
</source>


=Statistics=
=Estadísticas=
To count number of changes developers have made between a version x and y:
Para contar el número de cambios que los desarrolladores han realizado entre una versión x e y:
* First, run git merge-base to know the id of last common commit between x and y
* Primero, ejecute git merge-base para conocer el id del último commit común entre x e y
<source lang="bash">
<source lang="bash">
git merge-base origin/3.1 origin/develop
git merge-base origin/3.1 origin/develop
</source>
</source>
* Then run git log to have list of all changes from last common commit to last commit
* Entonces ejecutar un git log para obtener un listado desde el último commit común al último commit
<source lang="bash">
<source lang="bash">
git log id_found_at_previous_step..HEAD
git log id_found_at_previous_step..HEAD
</source>
</source>
* To get total number of added/deleted lines:
* Para obtener el total de líneas añadidas/eliminadas:
<source lang="bash">
<source lang="bash">
git log --ancestry-path --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
git log --ancestry-path --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
</source>
</source>


 
Para contar el número de cambios finales entre una versión x e y (se diferencia del recuento anterior porque en el recuento anterior, un cambio puede hacerse 2 veces en dos momentos diferentes para cambiar de forma diferente. Con el segundo método, se cuentan los cambios finales encontrados si los cambios estaban bien al primer intento):
To count number of changes finally between a version x and y (it differs from previous count because in previous count, a change can be done 2 times at two different moment to change differently. With second method, you count change finally found if changes were ok at first try):
* Usar el método anterior pero usando git diff.
* Use same method than previously but instead of running git log, run git diff.
<source lang="bash">
<source lang="bash">
git diff -b -M --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
git diff -b -M --numstat --pretty="%H" id_found_at_previous_step..HEAD | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}'
Line 200: Line 199:




More information in GIT usage is available [http://wiki.eclipse.org/EGit/User_Guide here].
Más información del uso de GIT disponible en [http://wiki.eclipse.org/EGit/User_Guide here].

Navigation menu