Difference between revisions of "TubeTK/Development/GITConfiguration"
|Line 5:||Line 5:|
== Windows ==
== Windows ==
* These [http://nathanj.github.com/gitguide/tour.html instructions] are a useful guide.
* These [http://nathanj.github.com/gitguide/tour.html instructions] are a useful guide .
* Install [http://code.google.com/p/msysgit/ msysgit]
= Local Configuration =
= Local Configuration =
Revision as of 22:49, 5 January 2011
sudo apt-get install git-core
- These instructions are a useful guide to using git on Windows.
- Install msysgit
- During the installation, make sure you add Windows Explorer integration, selecting both "Add Git Bash Here" and "Add Git GUI Here"
- Once you've installed msysgit, you can right-click on any folder to open Git GUI (graphical user interface to git) or Git Bash (console interface to git)
- Selecting "git bash" allows you to enter the git commands listed in these wiki pages
These steps are a one-time setup per-user per-machine.
--global option stores the configuration settings in
~/.gitconfig in your home directory so that they apply to all repositories.
We require all commits in TubeTK to record valid author/committer name and email information. Use git config to introduce yourself to Git:
$ git config --global user.name "Your Name" $ git config --global user.email "email@example.com"
Note that "Your Name" is your real name (e.g. "John Doe", not "jdoe"). While you're at it, optionally enable color output from Git commands:
$ git config --global color.ui auto
If less displays strange characters and no color, your LESS environment variable may already be set. You can override the less options with:
$ git config --global core.pager "less -FXRS"
The git commit command creates local commits.
A separate git push step is needed to publish commits to a
public.kitware.com server enforces some rules on the commits it accepts and will reject non-conforming commits.
In order to push rejected commits, one must edit history locally to repair them before publishing.
Since it is possible to create many commits locally and push them all at once, we provide local Git hooks to help developers keep their individual commits clean. Enabling these hooks will prevent problems when pushing your contributions to the public TubeTK repository. Git provides no way to enable such hooks by default, giving developers maximum control over their local repositories. We recommend enabling our hooks manually in all clones.
Git looks for hooks in the
.git/hooks directory within the work tree of a local repository.
Create a new local repository in this directory to manage the hooks and fetch VTK's hooks into that directory.
$ cd ~/src/tubetk/.git/hooks $ git init $ git pull git://public.kitware.com/VTK.git hooks $ cd ../..
~/src/tubetk is your TubeTK source directory.
See Git help on githooks for more details.
This runs during
git commit. It checks identity and the content of changes. It ensures that:
user.emailare set to something reasonable
- Git's standard whitespace checks pass (see help on
git diff --check)
- The staged changes do not introduce any leading TABs in source files (we indent with spaces)
- File modes look reasonable (no executable .cxx files, scripts with shebang lines are executable)
- File sizes are not too large (don't commit big data files; prints limit and instructions on rejection)
- Submodule updates are staged alone or explicitly allowed (prints instructions on rejection)
One of Git's standard whitespace checks is to reject trailing whitespace on lines that were added or modified. Many people consider extra space characters at the end of a line to be an unprofessional style (including Git's own developers), but some don't care. Text editors typically have a mode to highlight trailing whitespace:
(custom-set-variables '(show-trailing-whitespace t))
:highlight ExtraWhitespace ctermbg=red guibg=red :match ExtraWhitespace /\s\+$/
To toggle viewing of white space characters, with a source file document active, choose the menu item: Edit > Advanced > View White Space (2-stroke keyboard shortcut: Ctrl+R, Ctrl+W)
To eliminate trailing white space, choose the menu item: Edit > Trim Trailing Space To toggle viewing of white space characters, choose from the menu items: View > Show Symbol > (multiple items, choose one...)
|Qt Creator (v2.0.1)||
To eliminate trailing white space, choose the menu item: Tools > Options > Behavior > Clean whitespace To toggle viewing of white space characters, choose from the menu items: Tools > Options > Display > Visualize whitespace
- Optional: KWStyle style check (aborts commit on style check failure).
Disabled by default, but can be enabled to run a style check with KWStyle. To enable this hook:
git config hooks.KWStyle true
- Optional: uncrustify code beautification.
Disabled by default, but can be enabled to propose style changes to the code. To enable this hook:
git config hooks.uncrustify true
Proposed style changes are not added to the commit until they have been manually brought in by the developer. This is performed with the developer's favorite merge program. For more information and a list of supported merge applications, see
git help mergetool
To configure your preferred merge program
git config merge.tool <toolname>
This runs during
git commit. It checks the commit message format:
- The first line must be between 8 and 78 characters long. If you were writing an email to describe the change, this would be the Subject line.
They MUST begin with 'ENH:', 'COMP:' 'STYLE:' or 'BUG:' prefixes.
BUG: - a change made to fix a runtime issue (crash, segmentation fault, exception, or incorrect result) COMP: - a fix for a compilation issue, error or warning, ENH: - new functionality added to the project (enhancement) STYLE: - a change that does not impact the logic or execution of the code. (improve coding style, comments, documentation).
- The first line must not have leading or trailing whitespace.
- The second line must be blank, if present.
- The third line and below may be free-form. Try to keep paragraph text formatted in 72 columns (this is not enforced).
GUI and text-based tools that help view history typically use the first line (Subject line) from the commit message to give a one-line summary of each commit. This allows a medium-level view of history, but works well only if developers write good Subject lines for their commits.
Examples of improper commit messages:
This is too short and not informative at all.
ENH: I did a really complicated change and I am trying to describe the entire thing with a big message entered on the command line.
Many CVS users develop the habit of using the "-m" commit option to specify the whole message on the command line.
This is probably because in CVS it is hard to abort a commit if it already brought up the message editor.
In Git this is trivial. Just leave the message blank and the whole commit will be aborted.
Furthermore, since commits are not published automatically it is easy to allow the commit to complete and then fix it with
git commit --amend.
public.kitware.com repositories have server-side hooks.
The update hook runs when someone tries to update a ref on the server by pushing. The hook checks all commits included in the push:
- Commit author and committer must have valid email address domains (DNS lookup succeeds).
- Commit message does not start with "
WIP:". (Use the prefix locally for work-in-progress that must be rewritten before publishing.)
- Changes to paths updated by robots (such as Utilities/kwsys) are not allowed.
- No "large" blobs may be pushed. The limit is set on a per-repository basis and is typically 1MB or so.
- No CRLF newlines may be added in the repository (see core.autocrlf in
git help config).
- Submodules (if any) must be pushed before the references to them are pushed.