Source code management/es: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
Line 1: Line 1:
<languages/>
Our main source code management tool is [http://en.wikipedia.org/wiki/Git_%28software%29 git]. This article explains how to use it and how some general rules apply in the case of FreeCAD. You are highly advised to learn how git works first (there are a lot of tutorials and docs available for git on the internet) before working with the FreeCAD source code.
Our main source code management tool is [http://en.wikipedia.org/wiki/Git_%28software%29 git]. This article explains how to use it and how some general rules apply in the case of FreeCAD. You are highly advised to learn how git works first (there are a lot of tutorials and docs available for git on the internet) before working with the FreeCAD source code.


There are also many good graphical clients to git, such as [http://github.com/git-cola/git-cola git-cola], that make the whole process of managing git repositories easier.
There are also many good graphical clients to git, such as [http://github.com/git-cola/git-cola git-cola], that make the whole process of managing git repositories easier. FYI there also exists a cursory intro to [[Developing FreeCAD with GitKraken]].


== Source Code Access ==
== Source Code Access ==
Everybody can access and get a copy of the FreeCAD source code, but only the FreeCAD project managers have write access to it. You can get a copy of the code, study it and modify it as you wish, but if you make a change that you wish to see included in the official source code, you need to ask for a pull request on the [http://forum.freecadweb.org/viewforum.php?f=17 pull requests] section of the FreeCAD forum.
Everybody can access and get a copy of the FreeCAD source code, but only the FreeCAD project managers have write access to it. You can get a copy of the code, study it and modify it as you wish, but if you make a change that you wish to see included in the official source code, you need to ask for a pull request on the [http://forum.freecadweb.org/viewforum.php?f=17 pull requests] section of the FreeCAD forum.


{{Note|NOTE|In all examples below, "USERNAME" represents your GitHub user account.}}
{{Note|NOTE|In all examples below, "GITHUB_USERNAME" represents your GitHub user account.}}


=== Official GitHub Repo ===
=== Official GitHub Repo ===
An easy way to start with the FreeCAD source code is using the official FreeCAD repository at
An easy way to start with the FreeCAD source code is using the official FreeCAD repository at
https://github.com/FreeCAD/FreeCAD
'''https://github.com/FreeCAD/FreeCAD'''


<div class="mw-translate-fuzzy">
=== Setting your git username ===
=== Configurando tu nombre de usuario en Git ===
Users should commit to their project repository using their GitHub username.

If that is not already set globally, you can set it locally for the current Git repository like this:
Los usuarios deberían enviar a sus repositorios de proyecto utilizando sus nombres de usuario de SourceForge.net. Si no está definido globalmente, lo puedes definir localmente para el repositorio de Gir actual así:
</div>
git config user.name "YOUR NAME"
git config user.name "YOUR NAME"
git config user.email "USERNAME@users.noreply.github.com"
git config user.email "GITHUB_USERNAME@users.noreply.github.com"
Ahora puedes utilizar alguna combinación de los comandos "git add" y "git commit" para crear uno o más envíos en tu repositorio local.
Ahora puedes utilizar alguna combinación de los comandos "git add" y "git commit" para crear uno o más envíos en tu repositorio local.


==== Fork on GitHub ====
==== A note about Remotes ====
Please read some [https://stackoverflow.com/questions/9257533/what-is-the-difference-between-origin-and-upstream-on-github#9257901 background] to help you understand better the difference between what '''origin''' and '''upstream''' mean in the context of git. This section explains how to set the correct upstream and origin remote git repos.
You can start simply by using the "fork" button on top of the above page. This will create a copy of the FreeCAD repository on your own GitHub account. The general procedure is as follows:
Essentially:
# [https://github.com/join Sign up] for a GitHub account
# Go to the FreeCAD repo: https://github.com/FreeCAD/FreeCAD
* '''origin''' = Your fork of the FreeCAD git repo AKA https://github.com/GITHUB_USERNAME/FreeCAD.git
* '''upstream''' = The official FreeCAD git repo AKA https://github.com/FreeCAD/FreeCAD.git
# Press the "Fork" button
This is important to understand because if you git clone directly from upstream then confusingly, your origin will be listed as https://github.com/FreeCAD/FreeCAD.git
# On your machine, clone your newly created FreeCAD fork:
So, based on the above, there are 2 main ways to setup your git environment:
#: <pre>git clone https://github.com/USERNAME/FreeCAD.git</pre>
* [[Source_code_management#Clone_Official_FreeCAD_git_repo_to_your_local_machine|1st Method: Fork on GitHub and clone your fork locally]]
# Create and checkout a new branch simultaneously
* [[Source_code_management#Clone_Official_FreeCAD_git_repo_to_your_local_machine|2nd Method: Clone FreeCAD official directly to your local machine]]
#: <pre>git checkout -b newfeature</pre>
We recommend the 1st method for the reason mentioned above.
# Commit your changes to that new branch
# Push that new branch to your GitHub repo


==== Git clone to your local machine ====
==== 1st Method: Fork on GitHub and clone your fork locally ====
{{Note|Important Note|You will need to re-configure 'remote upstream' as mentioned above in "[[Source_code_management#A_note_about_Remotes|A note about Remotes]]"}}
You can also start normally, without using the "fork" button:
This method is the recommended way since it takes less steps. You will essentially fork the FreeCAD repo on your own GitHub account and then clone said GitHub fork locally. Then you will set your '''upstream''' repo in git. The procedure is as follows:
# Clone the FreeCAD code with git:
<ol>
#: <pre>git clone https://github.com/FreeCAD/FreeCAD.git</pre>
<li>[https://github.com/join Sign up] for a GitHub account if you don't already have one </li>
# Create and checkout a new branch simultaneously
<li>Go to the FreeCAD repo: https://github.com/FreeCAD/FreeCAD</li>
#: <pre>git checkout -b newfeature</pre>
<li>In the top right of the page find and press the "Fork" button (this will essentially git clone the official FreeCAD repo to your personal GitHub repo: https://github.com/GITHUB_USERNAME/FreeCAD.git) </li>
# Commit your changes to that new branch
<li>On your machine, clone your newly created FreeCAD fork by opening a terminal and typing:
# Create an account on a public git server (GitHub, GitLab, etc...)
<pre>git clone https://github.com/GITHUB_USERNAME/FreeCAD.git</pre></li>
# Push your branch to that server
<li>Once the clone process is complete, now set your '''upstream''' remote repo (see "[[Source_code_management#A_note_about_Remotes|A note about Remotes]]"). Find out what and where your remote git repositories are set to. Type '''git remote -v''' and the output should look similiar to:
<pre> [foo@bar FreeCAD]$ git remote -v
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (push)</pre></li>
<li>Great. Now set your '''upstream''' repo
<pre>[foo@bar FreeCAD]$ git remote add upstream https://github.com/FreeCAD/FreeCAD.git</pre></li>
<li>Check your remotes again, they should look similiar to this:
<pre> [foo@bar FreeCAD]$ git remote -v
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (push)
upstream https://github.com/FreeCAD/FreeCAD.git (fetch)
upstream https://github.com/FreeCAD/FreeCAD.git (push)</pre></li>
</li>
<li>Now we can start developing. Please refer to "[[Source_code_management#Git_Development_Process|Git Development Process]]"</li>
</ol>


==== 2nd Method: Clone Official FreeCAD git repo to your local machine ====
''Important Note'': If you have code you wish to see merged into the FreeCAD source code, please post a note in the [http://forum.freecadweb.org/viewforum.php?f=17 Pull Requests] section of the FreeCAD forum.
{{Note|Important Note|You will need to re-configure both 'remote origin' and 'remote upstream' please refer to above "[[Source_code_management#A_note_about_Remotes|A note about Remotes]]"}}
This method of setuping your git environment takes a few more steps then the 1st method. You will clone the FC git repo directly to your local machine and then alter your remotes via the terminal. The procedure is as follows:
<ol>
<li>Clone the FreeCAD code with git:
<pre>git clone https://github.com/FreeCAD/FreeCAD.git</pre></li>
<li>Create an account on a public git server (GitHub, GitLab, etc... for our purposes we're assuming it's GitHub)</li>
<li>Find out what and where your remote git repositories are set to:
<pre>git remote -v</pre></li>
<li>This will return something that looks like the following:
<pre>[foo@bar FreeCAD]$ git remote -v
origin https://github.com/FreeCAD/FreeCAD.git (fetch)
origin https://github.com/FreeCAD/FreeCAD.git (push)</pre></li>
<li>As was explained above in "[[Source_code_management#A_note_about_Remotes|A note about Remotes]]" you need to modify these remote git repo addresses.<br />
So first set up your '''origin''' remote:
<pre>[foo@bar FreeCAD]$ git remote add origin https://github.com/GITHUB_USERNAME/FreeCAD.git</pre></li>
<li>Then we set up our '''upstream''' remote:
<pre>[foo@bar FreeCAD]$ git remote add upstream https://github.com/FreeCAD/FreeCAD.git</pre></li>
<li>Check your remotes again, they should look similiar to this:
<pre> [foo@bar FreeCAD]$ git remote -v
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
origin https://github.com/GITHUB_USERNAME/FreeCAD.git (push)
upstream https://github.com/FreeCAD/FreeCAD.git (fetch)
upstream https://github.com/FreeCAD/FreeCAD.git (push)</pre></li>
<li>Now we can start developing. Please refer to "[[Source_code_management#Git_Development_Process|Git Development Process]]"</li>
</ol>


<div class="mw-translate-fuzzy">
=== Alternative repositories ===
== En desarrollo ==
The beauty of git is that everybody can clone a project, and start modifying the code. Several frequent collaborators of the FreeCAD project have their own git repository, where they build up their work before it is ready to be included in the official source code, or simply where they experiment new ideas. In certain cases, you might want to clone your FreeCAD code from one of these, instead of the official repos, to benefit from the changes their users did.
Antes de nada '''nunca desarrolles en el '''ramal principal'''! Crea un ramal local para el desarrollo.

Puedes aprender a hacer esto [http://book.git-scm.com/3_basic_branching_and_merging.html aquí].
Be warned, though, that this is at your own risk, and only the official repository above is fully guaranteed to work and contain clean code.
</div>

It is also possible to attach several remote repositories to a same local FreeCAD git code, using the "git remote" command. This is useful to keep in sync with the master code branch, but keep an eye on the work of different developers.

== Git Development Process ==
First of all '''never develop on the ''master'' branch!''' Create a local branch for development.
You can learn how to do this [http://book.git-scm.com/3_basic_branching_and_merging.html here].


=== Ramificado ===
=== Ramificado ===
Line 63: Line 100:
siempre puedes comprobar con que rama estas:
siempre puedes comprobar con que rama estas:
git branch
git branch

=== Envío ===
=== Envío ===


Una vez que hagas algo de trabajo, envíalo con:
Una vez que hagas algo de trabajo, envíalo con:
git commit -a
<pre>git commit -a</pre>
A diferencia de SVN, tienes que especificar los archivos que quieres enviar (o todos con la opción -a). Tu editor de texto se abrirá para permitirte escribir un mensaje de envío.
A diferencia de SVN, tienes que especificar los archivos que quieres enviar (o todos con la opción -a). Tu editor de texto se abrirá para permitirte escribir un mensaje de envío.


<div class="mw-translate-fuzzy">
=== Publishing your work on your GitHub repository===
=== Publicación de tu trabajo en el repositorio de sourceforge ===
After done some changes on your local branch and commit it (this means commit

''locally'') you can push your repository to the server. This opens your branch
Después de hacer algunos cambios en tu ramal local y enviarlos (es decir, enviarlos "localmente") puedes enviar tu repositorio al servidor. Esto abre tu ramal al público y permite que los desarrolladores principales revisen e integren tu ramal en el ''principal''.
to the public and allows the main developers to review and integrate your
</div>
branch into ''master''.
git push my-branch
git push <REMOTENAME> <BRANCHNAME>
git push origin my-branch
<small>For further info on this subject please read https://help.github.com/articles/pushing-to-a-remote/</small>


=== Escribiendo buenos mensajes de envío ===
=== Escribiendo buenos mensajes de envío ===
Line 98: Line 138:


Si estas haciendo un montón de trabajo relacionado, se sugiere [http://forum.freecadweb.org/viewtopic.php?f=10&t=2062&p=14887#p14886 aquí] que deberías hacer tantos envíos grandes o pequeños como sea necesario para que tengan sentido en lo que estés trabajando utilizado los mensajes cortos de envío. Cuando quieras fusionarlos, haz un registro master..BRANCH y utiliza el resultado para tu mensaje de envío. Cuando fusionas con el principal utiliza la opción --squash y envía con tu mensaje de envío. Esto te permitirá ser muy liberal con tus envíos y ayudar a proporcionar un buen nivel de detalle en los mensajes de envío sin demasiadas descripciones distintas.
Si estas haciendo un montón de trabajo relacionado, se sugiere [http://forum.freecadweb.org/viewtopic.php?f=10&t=2062&p=14887#p14886 aquí] que deberías hacer tantos envíos grandes o pequeños como sea necesario para que tengan sentido en lo que estés trabajando utilizado los mensajes cortos de envío. Cuando quieras fusionarlos, haz un registro master..BRANCH y utiliza el resultado para tu mensaje de envío. Cuando fusionas con el principal utiliza la opción --squash y envía con tu mensaje de envío. Esto te permitirá ser muy liberal con tus envíos y ayudar a proporcionar un buen nivel de detalle en los mensajes de envío sin demasiadas descripciones distintas.

== Advanced git operations ==
=== Resolving Merge Conflicts ===
* [https://git-scm.com/docs/git-merge#_how_conflicts_are_presented git-scm explanation on how conflicts are presented]
* [https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/ GitHub article on resolving merge conflicts via the command-line]
* [https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_external_merge_tools Customize your preferred merge tool] when you encounter a git conflict.

=== Applying patches via git ===
Git has the capability to merge patches/diffs. To read more about this read the following reference: https://www.drupal.org/node/1399218
* Useful tip: Just add .diff or .patch at the end of the URL for a GitHub commit page, Pull Request, or Compare View and it'll show you the plaintext view of that page. Example:
Regular GitHub page:
<small>https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621</small>

'Diffed' GitHub page:
<small>https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.diff</small>

'Patched' GitHub page:
<small>https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.patch</small>

==== Apply a patch via curl ====
curl https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.patch | git apply -

=== Creating patches from git ===
There are times when one may need to create a patch instead of submitting a PR. The following workflow explains how to do this:
<ol>
<li>Make sure you are in the correct branch (i.e. not the master branch) by checking with
<pre>git branch -v</pre></li>
<li>Create the patch: we do this by using the '''git format-patch''' command which we patch against the master branch and redirect to STDOUT. We create the patch in the directory outside of the source build (in order not to pollute the source dir itself, this is optional as you can decide the location wherever you want the patch to be created)
<pre>git format-patch master --stdout > ../patch.name.patch</pre></li>
</ol>

== What is the latest FreeCAD Dev Revision ==
There are 2 ways to do this:
* 1st method: In your cloned git directory type:
git rev-list --count master
* 2nd method: Browse https://github.com/FreeCAD/FreeCAD and read the amount of commits FreeCAD is at.

== Alternative repositories ==
The beauty of git is that everybody can clone a project, and start modifying the code. Several frequent collaborators of the FreeCAD project have their own git repository, where they build up their work before it is ready to be included in the official source code, or simply where they experiment new ideas. In certain cases, you might want to clone your FreeCAD code from one of these, instead of the official repos, to benefit from the changes their users did.

Be warned, though, that this is at your own risk, and only the official repository above is fully guaranteed to work and contain clean code.

It is also possible to attach several remote repositories to a same local FreeCAD git code, using the "git remote" command. This is useful to keep in sync with the master code branch, but keep an eye on the work of different developers.

== Using git in a Graphical User Interface ==
* [[Developing FreeCAD with GitKraken]]


== Otras lecturas ==
== Otras lecturas ==
Line 108: Line 194:


{{clear}}
{{clear}}
<languages/>

Revision as of 19:24, 8 August 2018

Our main source code management tool is git. This article explains how to use it and how some general rules apply in the case of FreeCAD. You are highly advised to learn how git works first (there are a lot of tutorials and docs available for git on the internet) before working with the FreeCAD source code.

There are also many good graphical clients to git, such as git-cola, that make the whole process of managing git repositories easier. FYI there also exists a cursory intro to Developing FreeCAD with GitKraken.

Source Code Access

Everybody can access and get a copy of the FreeCAD source code, but only the FreeCAD project managers have write access to it. You can get a copy of the code, study it and modify it as you wish, but if you make a change that you wish to see included in the official source code, you need to ask for a pull request on the pull requests section of the FreeCAD forum.

NOTE

In all examples below, "GITHUB_USERNAME" represents your GitHub user account.


Official GitHub Repo

An easy way to start with the FreeCAD source code is using the official FreeCAD repository at https://github.com/FreeCAD/FreeCAD

Configurando tu nombre de usuario en Git

Los usuarios deberían enviar a sus repositorios de proyecto utilizando sus nombres de usuario de SourceForge.net. Si no está definido globalmente, lo puedes definir localmente para el repositorio de Gir actual así:

git config user.name "YOUR NAME"
git config user.email "GITHUB_USERNAME@users.noreply.github.com"

Ahora puedes utilizar alguna combinación de los comandos "git add" y "git commit" para crear uno o más envíos en tu repositorio local.

A note about Remotes

Please read some background to help you understand better the difference between what origin and upstream mean in the context of git. This section explains how to set the correct upstream and origin remote git repos. Essentially:

This is important to understand because if you git clone directly from upstream then confusingly, your origin will be listed as https://github.com/FreeCAD/FreeCAD.git So, based on the above, there are 2 main ways to setup your git environment:

We recommend the 1st method for the reason mentioned above.

1st Method: Fork on GitHub and clone your fork locally

Important Note

You will need to re-configure 'remote upstream' as mentioned above in "A note about Remotes"

This method is the recommended way since it takes less steps. You will essentially fork the FreeCAD repo on your own GitHub account and then clone said GitHub fork locally. Then you will set your upstream repo in git. The procedure is as follows:

  1. Sign up for a GitHub account if you don't already have one
  2. Go to the FreeCAD repo: https://github.com/FreeCAD/FreeCAD
  3. In the top right of the page find and press the "Fork" button (this will essentially git clone the official FreeCAD repo to your personal GitHub repo: https://github.com/GITHUB_USERNAME/FreeCAD.git)
  4. On your machine, clone your newly created FreeCAD fork by opening a terminal and typing:
    git clone https://github.com/GITHUB_USERNAME/FreeCAD.git
  5. Once the clone process is complete, now set your upstream remote repo (see "A note about Remotes"). Find out what and where your remote git repositories are set to. Type git remote -v and the output should look similiar to:
     [foo@bar FreeCAD]$ git remote -v
         origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
         origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (push)
  6. Great. Now set your upstream repo
    [foo@bar FreeCAD]$ git remote add upstream https://github.com/FreeCAD/FreeCAD.git
  7. Check your remotes again, they should look similiar to this:
     [foo@bar FreeCAD]$ git remote -v
        origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
        origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (push)
        upstream	https://github.com/FreeCAD/FreeCAD.git (fetch)
        upstream	https://github.com/FreeCAD/FreeCAD.git (push)
  8. Now we can start developing. Please refer to "Git Development Process"

2nd Method: Clone Official FreeCAD git repo to your local machine

Important Note

You will need to re-configure both 'remote origin' and 'remote upstream' please refer to above "A note about Remotes"

This method of setuping your git environment takes a few more steps then the 1st method. You will clone the FC git repo directly to your local machine and then alter your remotes via the terminal. The procedure is as follows:

  1. Clone the FreeCAD code with git:
    git clone https://github.com/FreeCAD/FreeCAD.git
  2. Create an account on a public git server (GitHub, GitLab, etc... for our purposes we're assuming it's GitHub)
  3. Find out what and where your remote git repositories are set to:
    git remote -v
  4. This will return something that looks like the following:
    [foo@bar FreeCAD]$ git remote -v
        origin https://github.com/FreeCAD/FreeCAD.git (fetch)
        origin https://github.com/FreeCAD/FreeCAD.git (push)
  5. As was explained above in "A note about Remotes" you need to modify these remote git repo addresses.
    So first set up your origin remote:
    [foo@bar FreeCAD]$ git remote add origin https://github.com/GITHUB_USERNAME/FreeCAD.git
  6. Then we set up our upstream remote:
    [foo@bar FreeCAD]$ git remote add upstream https://github.com/FreeCAD/FreeCAD.git
  7. Check your remotes again, they should look similiar to this:
     [foo@bar FreeCAD]$ git remote -v
        origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (fetch)
        origin	https://github.com/GITHUB_USERNAME/FreeCAD.git (push)
        upstream	https://github.com/FreeCAD/FreeCAD.git (fetch)
        upstream	https://github.com/FreeCAD/FreeCAD.git (push)
  8. Now we can start developing. Please refer to "Git Development Process"

En desarrollo

Antes de nada nunca desarrolles en el ramal principal! Crea un ramal local para el desarrollo. Puedes aprender a hacer esto aquí.

Ramificado

Una importante característica de Git es que es extremadamente sencillo trabajar con ramas y fusionarlas. La mejor forma de trabajar recomienda crear una nueva rama siempre que quieras trabajar en una nueva característica. La creación de una rama se hace con:

git branch myNewBranch
git checkout myNewBranch

o, ambas operaciones en una:

git checkout -b myNewBranch

siempre puedes comprobar con que rama estas:

git branch

Envío

Una vez que hagas algo de trabajo, envíalo con:

git commit -a

A diferencia de SVN, tienes que especificar los archivos que quieres enviar (o todos con la opción -a). Tu editor de texto se abrirá para permitirte escribir un mensaje de envío.

Publicación de tu trabajo en el repositorio de sourceforge

Después de hacer algunos cambios en tu ramal local y enviarlos (es decir, enviarlos "localmente") puedes enviar tu repositorio al servidor. Esto abre tu ramal al público y permite que los desarrolladores principales revisen e integren tu ramal en el principal.

git push  <REMOTENAME> <BRANCHNAME> 
git push origin my-branch

For further info on this subject please read https://help.github.com/articles/pushing-to-a-remote/

Escribiendo buenos mensajes de envío

Deberías tratar de trabajar en pedazos pequeños. Si no puedes resumir tus cambios en una frase, entonces posiblemente ha pasado pasado demasiado tiempo desde que hiciste un envío. También es importante que ofrezcas descripciones de tu trabajo que sean útiles y ayuden. Para los mensajes de envío, FreeCAD ha adoptado un formato mencionado en el libro Pro Git (mira #Otras lecturas).

 Resumen corto (50 caracteres o menos) de cambios
Texto de explicación más detallado, si es necesario. En unos 72 caracteres.
En algunos contextos, la primera línea es tratada como el tema
de un email y el resto del texto como el cuerpo. La línea en blanco
separando el tema del cuerpo es crítica (a menos que omitas el cuerpo por
completo); las herramientas de recálculo se pueden confundir si pones los
dos juntos.

Más párrafos van después de líneas en blanco. 

 - Las listas con viñetas también están bien

 - Tipicamente un guión o asterisco se utiliza para la viñeta, precedido 
   por un espacio en blanco, con líneas en blanco en medio, pero las 
   convenciones aquí varían

Si estas haciendo un montón de trabajo relacionado, se sugiere aquí que deberías hacer tantos envíos grandes o pequeños como sea necesario para que tengan sentido en lo que estés trabajando utilizado los mensajes cortos de envío. Cuando quieras fusionarlos, haz un registro master..BRANCH y utiliza el resultado para tu mensaje de envío. Cuando fusionas con el principal utiliza la opción --squash y envía con tu mensaje de envío. Esto te permitirá ser muy liberal con tus envíos y ayudar a proporcionar un buen nivel de detalle en los mensajes de envío sin demasiadas descripciones distintas.

Advanced git operations

Resolving Merge Conflicts

Applying patches via git

Git has the capability to merge patches/diffs. To read more about this read the following reference: https://www.drupal.org/node/1399218

  • Useful tip: Just add .diff or .patch at the end of the URL for a GitHub commit page, Pull Request, or Compare View and it'll show you the plaintext view of that page. Example:

Regular GitHub page: https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621

'Diffed' GitHub page: https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.diff

'Patched' GitHub page: https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.patch

Apply a patch via curl

curl https://github.com/FreeCAD/FreeCAD/commit/c476589652a0f67b544735740e20ff702e8d0621.patch | git apply -

Creating patches from git

There are times when one may need to create a patch instead of submitting a PR. The following workflow explains how to do this:

  1. Make sure you are in the correct branch (i.e. not the master branch) by checking with
    git branch -v
  2. Create the patch: we do this by using the git format-patch command which we patch against the master branch and redirect to STDOUT. We create the patch in the directory outside of the source build (in order not to pollute the source dir itself, this is optional as you can decide the location wherever you want the patch to be created)
    git format-patch master --stdout > ../patch.name.patch

What is the latest FreeCAD Dev Revision

There are 2 ways to do this:

  • 1st method: In your cloned git directory type:
git rev-list --count master

Alternative repositories

The beauty of git is that everybody can clone a project, and start modifying the code. Several frequent collaborators of the FreeCAD project have their own git repository, where they build up their work before it is ready to be included in the official source code, or simply where they experiment new ideas. In certain cases, you might want to clone your FreeCAD code from one of these, instead of the official repos, to benefit from the changes their users did.

Be warned, though, that this is at your own risk, and only the official repository above is fully guaranteed to work and contain clean code.

It is also possible to attach several remote repositories to a same local FreeCAD git code, using the "git remote" command. This is useful to keep in sync with the master code branch, but keep an eye on the work of different developers.

Using git in a Graphical User Interface

Otras lecturas