FAQ Recuperar, actualizar GIT fuentes del proyecto
Esta es información sobre cómo puede obtener las fuentes del proyecto Dolibarr.
Obtener la última versión de los fuentes por descarga
Este método le permite obtener los fuentes de la rama de desarrollo principal (Llamada HEAD). La operación consiste en recuperar la última versión de los archivos de la aplicación Dolibarr que son compilados cada noche en un archivo. Este archivo se encuentra disponible en el siguiente enlace:
Last GitHub snapshot of Dolibarr source files.
Los nuevos archivos reemplazarán los antiguos
El problema de este método es que hace falta descargar y descomprimir el paquete cada vez que deseemos actualizar.
Obtener la última versión de los fuentes usando un acceso anónimo GIT
Prerrequisitos
Debe tener una instalación funcional de Eclispe, el plugin EGit también debe estar instalado. 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 :
http://download.eclipse.org/egit/updates
Seguidamente escoja instalar EGit.
Para obtener los fuentes con el objetivo de editarlos, necesita un GitHub con acceso de escritura al repositorio Git remoto y un cliente GIT (herramienta en línea de comandos en linux o el cliente GIT en Eclipse). Vea el siguiente capítulo para ello..
En primer lugar, introducir el valor del repositorio con los fuentes de referencia en la herramienta de cliente de GIT.
- Con Eclipse, escoja "Clone GIT repository". Introduzca la URL GIT del proyecto a obtener.
La Url para los fuentes oficiales de Dolibarr es:
git://github.com/Dolibarr/dolibarr.git
Su cliente GIT de Eclipse le preguntará en que ramas está interesado. Las ramas no seleccionadas podrán seleccionarse después mediante un "Fetch" desde la vista "Remotes", pero trate de elegir sólo la rama que usted necesita. Esto le ahorrará tiempo y problemas en el futuro.
- Con GIT desde la línea de comandos:
Primero configure su cliente GIT:
git config --global user.name "Su Nombre"
git config --global user.email "usuario@dominio.com"
git config --list
Clone el repositorio localmente:
git clone git://github.com/Dolibarr/dolibarr.git dolibarr
Y si usa firewall, puede usar la URL alternativa:
git config --global http.proxy http://proxyuser:proxypass@proxyserver:proxyport
git clone https://gitlogin:gitpassword@github.com/Dolibarr/dolibarr.git dolibarr
Una vez que este paso se valida, el cliente de GIT se descargará todos los archivos del servidor GIT remoto. Esto puede durar varios segundos o minutos. Una vez que la descarga haya finalizado, vaya a la vista GIT - Branches - Local. En la mayoría de los casos, la rama que ha escogido ya está disponible.
Si no:
- Con Eclipse, haga click con el botón derecho en"Branches - Remotes - La rama que desea clonar localmente".
Si escoge "Create Branch", duplicará el contenido de la rama para trabajar en forma local. Si escoge "Checkout", actualizará la vista "Working Directory".
- Con GIT desde la línea de comandos:
git checkout develop
git checkout x.y
Esto creará la rama local y realizará un checkout de forma automática.
Si usa Eclipse, una vez que su rama se crea a nivel local, cree un proyecto de PHP a partir del asistente eligiendo "Create from existing project" y seleccione el directorio de su repositorio GIT local (No use create a PHP project from scratch). A continuación haga click con el botón derecho del ratón en su workspace y escoja "Team - Share". Seleccione GIT y haga click en la opción "Use or create repository in parent folder of project".
Un método alternativo es usar el menú File->Import, Git->Project from Git, Seleccione el repositorio GIT y haga click en Next, Use New project Wizard -> Php project, indique el directorio de su repositorio local GIT.
Seguidamente, puede configurar Eclipse para evitar analizar todos los archivos del proyecto (Outline scanner, TODO scanner, syntax scanner...). Esto evitará que Eclipse se vuelva lento. Para ello, haga clic derecho en el proyecto, elija Build Path y configure como la siguiente captura de pantalla.
Get last version of sources using a full GIT access
Prerequisite
First you must have a working install of Eclipse. EGit plugin must also have been installed. For this, use the Find And Install process into Eclipse menu, add the GIT update URL:
http://download.eclipse.org/egit/updates
Then choose to install EGit.
You must before create an account on GitHub (https://github.com/) and upload a public RSA or DSA certificate into your account profile.
Then process is same than getting sources with anonymous access.
URL to use for GIT clone is same:
git@github.com:Dolibarr/dolibarr.git
Note that a HTTP URL is also available but it's sometimes offline (so use first one instead):
https://yourgitlogin@github.com/Dolibarr/dolibarr.git
Update your repository
To update your local workspace, right click on Eclipse project and select "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.
- 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". All you have to do is make a commit to validate your local repository as including your changes and changes made by others.
Commit and publish your changes
To see all changes you made into your working directory and waiting to be added into Git:
- With GIT Command Line Interface:
git status
git diff subdir/filename
To add changes made into your local repository into the GIT index, then commit this index :
- With Eclipse: Right click on file or directory to commit. Select file to add/remove/update into commit.
- With GIT Command Line Interface:
git commit -a -m "Commit text"
This will save add and changes into your local branch.
To push them on the GIT repository server,
- With Eclipse: right click on project and choose "Team - Push to Upstream".
- With GIT Command Line Interface:
git push
To cancel a commit:
- With GIT Command Line Interface:
git revert IdCommit or git revert HEAD (for last commit)
Add an external commit into current repository
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:
- First, go into GIT setup view and right click on "Remotes" of your Eclipse Git working space and choose "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".
- 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.
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:
git cherry-pick -x commitid
where commitid is value of commit id you want to get.
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).
Solving a conflict
If a file has been marked as "conflict" after a Pull request, open the file to edit it. Find string "<<<<<<<<<<", you will see part of code that is conflict between "<<<<<<<<<" and ">>>>>>>>". Edit manually code lines and remove "<<<<<<<<" and ">>>>>>>".
Then, right click on file and select "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:
- With Eclipse, right click on project top line and select "Reset" then "Hard" then "Reference - HEAD".
- Using GIT command line tool, you can achieve this with command
git reset --hard HEAD
Tagging sources
To add a tag to a current version:
git tag -m "Tag for x.y.z_YYYYMMDD" "x.y.z_YYYYMMDD"
git push --tags
Creating a new branch
This is command used to start a new branch from a clean develop cloned repository:
git branch x.y
git push origin x.y
Statistics
To count number of changes developers have made between a version x and y:
- First, run git merge-base to know the id of last common commit between x and y
git merge-base origin/3.1 origin/develop
- Then run git log to have list of all changes from last common commit to last commit
git log id_found_at_previous_step..HEAD
- To get total number of added/deleted lines:
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)}'
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):
- Use same method than previously but instead of running git log, run git diff.
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)}'
More information in GIT usage is available here.