https://public.kitware.com/Wiki/api.php?action=feedcontributions&user=Demver5&feedformat=atomKitwarePublic - User contributions [en]2024-03-29T11:21:03ZUser contributionsMediaWiki 1.38.6https://public.kitware.com/Wiki/index.php?title=ITK/Git&diff=28817ITK/Git2010-08-19T07:04:41Z<p>Demver5: /* Resources */</p>
<hr />
<div>__TOC__<br />
<br />
ITK version tracking and development is hosted by [http://git-scm.com Git].<br />
<br />
=Official Repository=<br />
<br />
One may browse the repository online using the [http://git.wiki.kernel.org/index.php/Gitweb Gitweb] interface at http://itk.org/gitweb.<br />
<br />
==Cloning==<br />
<br />
Clone ITK using the command<br />
<br />
$ git clone git://itk.org/ITK.git<br />
<br />
If your institution's firewall blocks the Git port for outgoing connections you may see an error similar to:<br />
<br />
Initialized empty Git repository in C:/abc/ITK/.git/itk.org[0: 66.194.253.19]:<br />
errno=No such file or directory<br />
fatal: unable to connect a socket (No such file or directory)<br />
<br />
In that case, see [[#Firewall_Blocks_Port_9418|below]].<br />
<br />
If you want to run tests, add the <code>--recursive</code> option to download the <code>Testing/Data</code> submodule.<br />
<br />
$ git clone --recursive git://itk.org/ITK.git<br />
<br />
This requires Git 1.6.5 or higher. If you do not have it, see [[#Git Below 1.6.5|below]].<br />
<br />
All further commands work inside the local copy of the repository created by the clone:<br />
<br />
$ cd ITK<br />
<br />
If you already cloned and want to add the <code>Testing/Data</code> submodule then run<br />
<br />
$ git submodule update --init<br />
<br />
For ITKApps, use the url<br />
<br />
git://itk.org/ITKApps.git<br />
<br />
instead.<br />
<br />
==Updating==<br />
<br />
If you have made no local commits and simply want to update your clone with the latest changes, run<br />
<br />
$ git pull<br />
$ git submodule update<br />
<br />
If you know you do not have the <code>Testing/Data</code> submodule checked out then you can skip the submodule update command.<br />
<br />
==Branches==<br />
<br />
At the time of this writing the repository has the following branches:<br />
<br />
* '''master''': Development (default)<br />
* '''release''': Release maintenance<br />
* '''nightly-master''': Follows '''master''', updated at 01:00 UTC<br />
* '''hooks''': Local commit hooks ([[Git/Hooks#Local|place]] in .git/hooks)<br />
* '''dashboard''': Dashboard script (see [[#Dashboard|below]])<br />
<br />
Release branches converted from CVS have been artificially merged into master.<br />
Actual releases have tags named by the release version number.<br />
<br />
After cloning your local repository will be configured to follow the upstream '''master''' branch by default.<br />
One may create a local branch to track another upstream branch using [http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html git checkout]:<br />
<br />
$ git checkout -b release origin/release<br />
<br />
As a shortcut with Git >= 1.6.5 one may choose a branch during the initial clone:<br />
<br />
$ git clone -b release git://itk.org/ITK.git ITKRel<br />
<br />
=Development=<br />
<br />
We provide here a brief introduction to '''ITK''' development with Git.<br />
See the [[Git/Resources|Resources]] page for further information such as Git tutorials.<br />
<br />
==Introduction==<br />
<br />
We require all commits in ITK to record valid author/committer name and email information.<br />
Use [http://www.kernel.org/pub/software/scm/git/docs/git-config.html git config] to introduce yourself to Git:<br />
<br />
$ git config --global user.name "Your Name"<br />
$ git config --global user.email "you@yourdomain.com"<br />
<br />
Note that "Your Name" is your ''real name'' (e.g. "John Doe", not "jdoe").<br />
While you're at it, optionally enable color output from Git commands:<br />
<br />
$ git config --global color.ui auto<br />
<br />
If less displays strange characters and no color, your LESS environment variable may already be set. You can override the less options with:<br />
<br />
$ git config --global core.pager "less -FXRS"<br />
<br />
The <code>--global</code> option stores the configuration settings in <code>~/.gitconfig</code> in your home directory so that they apply to all repositories.<br />
<br />
==Hooks==<br />
<br />
The '''hooks''' branch provides local commit hooks to be placed in <code>.git/hooks</code>.<br />
It is shared by many <code>public.kitware.com</code> repositories.<br />
<br />
See the general [[Git/Hooks|hooks]] information page to set up your local hooks.<br />
<br />
==Workflow==<br />
<br />
We've chosen to approximate our previous CVS-based development workflow after the initial move to Git, at least while things get settled.<br />
The basic rule is to rebase your work on origin/master before pushing:<br />
<br />
git fetch origin<br />
git rebase origin/master<br />
<br />
or<br />
<br />
git pull --rebase<br />
<br />
The server will refuse your push if it contains any merges.<br />
Later we will move to a full [[Git/Workflow/Topic|branchy workflow]] based on topic branches.<br />
<br />
==Topic Stage==<br />
<br />
We provide a "[http://itk.org/stage/ITK.git ITK Topic Stage]" repository to which developers may publish arbitrary topic branches and request automatic merges.<br />
<br />
The topic stage URLs are<br />
<br />
* <code>git://itk.org/stage/ITK.git</code> (clone, fetch)<br />
* <code>http://itk.org/stage/ITK.git</code> (clone, fetch, gitweb)<br />
* <code>git@itk.org:stage/ITK.git</code> (push)<br />
<br />
See our [http://public.kitware.com/Wiki/Git/Workflow/Stage Topic Stage Workflow] documentation for general instructions.<br />
''(Currently ITK does not have a '''next''' branch. Just skip that part of the instructions and merge directly to master.)''<br />
When accessing the ITK stage, one may optionally substitute<br />
"<code>ssh git@itk.org stage ITK ...</code>"<br />
for<br />
"<code>ssh git@public.kitware.com stage <repo> ...</code>"<br />
in the ssh command-line interface.<br />
<br />
{| border="0"<br />
!colspan=2|Stage Usage Summary<br />
|-<br />
|align="center"|<br />
'''Initial Setup:'''<br />
|<br />
$ git remote add stage git://itk.org/stage/ITK.git<br />
$ git config remote.stage.pushurl git@itk.org:stage/ITK.git<br />
|-<br />
|align="center"|<br />
'''Fetch Staged Topics:'''<br />
|<br />
$ git fetch stage --prune<br />
|-<br />
|align="center"|<br />
'''Create Local Topic:'''<br />
|<br />
$ git checkout -b ''topic-name'' origin/master<br />
$ edit files<br />
$ git commit<br />
|-<br />
|align="center"|<br />
'''Stage Current Topic:'''<br />
|<br />
$ git push stage HEAD<br />
|-<br />
|align="center"|<br />
'''Print Staged Topics:'''<br />
|<br />
$ ssh git@itk.org stage ITK print<br />
|-<br />
|align="center"|<br />
'''Merge Staged Topic:'''<br />
|<br />
$ ssh git@itk.org stage ITK merge ''topic-name''<br />
|}<br />
<br />
Note that the stage implementation is not ITK-specific and is used for other projects too.<br />
If the merge attempt conflicts it may print instructions for performing the merge manually.<br />
'''Ignore''' these instructions; you will not be able to push the merge commit directly.<br />
Instead, identify the commit that conflicts with yours, merge it into your topic locally, push the topic to the stage again, and then repeat the merge request.<br />
<br />
=Publishing=<br />
<br />
==Pushing==<br />
<br />
Authorized developers may publish work directly to <code>itk.org/ITK.git</code> using Git's SSH protocol.<br />
To request access, fill out the [https://www.kitware.com/Admin/SendPassword.cgi Kitware Password] form.<br />
<br />
See the [[Git/Publish#Push_Access|push instructions]] for details.<br />
<br />
For ITK, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@itk.org:ITK.git<br />
<br />
For ITKApps, configure the push URL:<br />
<br />
git config remote.origin.pushurl git@itk.org:ITKApps.git<br />
<br />
===Update Hook===<br />
<br />
The itk.org repository has an <code>update</code> hook.<br />
When someone tries to push changes to the repository it checks the commits as documented [[Git/Hooks#update|here]].<br />
<br />
=Testing=<br />
<br />
==Dashboard==<br />
<br />
The [[#Branches| dashboard]] branch contains a dashboard client helper script.<br />
Use these commands to track it:<br />
<br />
$ mkdir -p ~/Dashboards/ITKScripts<br />
$ cd ~/Dashboards/ITKScripts<br />
$ git init<br />
$ git remote add -t dashboard origin git://itk.org/ITK.git<br />
$ git pull origin<br />
<br />
The <code>itk_common.cmake</code> script contains setup instructions in its top comments.<br />
Update the '''dashboard''' branch to get the latest version of this script by simply running<br />
<br />
$ git pull origin<br />
<br />
=Troubleshooting=<br />
<br />
==Firewall Blocks Port 9418==<br />
<br />
Some institutions have firewalls that block Git's native protocol port 9418.<br />
Use the "<code>url.<base>.insteadOf</code>" configuration option to map git URLs to http:<br />
<br />
<pre><br />
$ git config --global url.http://itk.org/.insteadOf git://itk.org/<br />
</pre><br />
<br />
This tells Git to translate URLs under the hood by replacing prefixes.<br />
After running these commands ''once'' in your home directory then you can just use the "<code>git://</code>" mentioned elsewhere on this page and git will use the http protocol automagically.<br />
<br />
==Git Below 1.6.5==<br />
<br />
To clone ITK using Git 1.6.4 or lower, use the commands<br />
<br />
$ git clone git://itk.org/ITK.git<br />
$ cd ITK<br />
$ git submodule init<br />
$ git submodule update<br />
<br />
== The remote end hung up unexpectedly ==<br />
<br />
If <code>git push</code> fails with<br />
<br />
fatal: The remote end hung up unexpectedly<br />
<br />
check that you set the pushurl with "<code>git config</code>".<br />
See the [[#Pushing|push instructions]].<br />
<br />
If you suspect your ssh key may not be configured correctly, see the [[Git/Publish#Authentication_Test|authentication test]] instructions.<br />
<br />
=Tips=<br />
<br />
==Tip: Renaming==<br />
<br />
Git does not explicitly track renames. The command<br />
<br />
$ git mv old new<br />
<br />
is equivalent to<br />
<br />
$ mv old new<br />
$ git add new<br />
$ git rm old<br />
<br />
Neither approach records the rename outright.<br />
However, Git's philosophy is "''dumb add, smart view''".<br />
It uses heuristics to ''detect'' renames when viewing history after-the-fact.<br />
It even works when the content of a renamed file changes slightly.<br />
<br />
In order to help Git efficiently detect the rename, it is important to remove the old file and add the new one in ''one commit'', perhaps by using <code>git mv</code> or the above 3-step procedure.<br />
If the new file were added in one commit and the old file removed in the next, Git would report this as a copy followed by a removal.<br />
It's copy-detection heuristics are more computationally intensive and must be explicitly enabled with the <code>-C</code> option to relevant operations (such as <code>git blame</code>).<br />
<br />
=Resources=<br />
<br />
Additional information about Git may be obtained at sites listed [[Git/Resources|here]].<br />
<br />
<br />
==Related Links==<br />
<br />
<br />
[http://www.cellulite.co.uk/how-to-get-rid-of-cellulite '''how to get rid of cellulite''']</div>Demver5