Red Hat

In Relation To Hibernate Validator

In Relation To Hibernate Validator

First Alpha release of Hibernate Validator 5

Posted by    |       |    Tagged as Hibernate Validator

Good news for all of you waiting for an early version of Hibernate Validator 5 in order to experiment with the new Bean Validation 1.1 (JSR 349) features. Hibernate Validator 5.0.0.Alpha1 is now available for download in the JBoss Maven Repository under the GAV org.hibernate:hibernate-validator:5.0.0.Alpha1 or via SourceForge.

The focus of the release was the alignment of Hibernate Validator with the first early draft of Bean Validation 1.1 (1.1.0.Alpha1). The Hibernate Validator changelog circles for this reason around HV-571 which served as placeholder for those specification changes. Of course the biggest change was the formalization of method validation, but there are other interesting new features as well. For example:

  • In conjunction with method validation it is worth having a look at the ParameterNameProvider interface which helps to identify the parameter of a failing parameter constraint in the resulting ConstraintViolation. The Path API was also extended to provide additional meta information about a failing constraint. You can get the element descriptor via Path.Node#getElementDescriptor (of course you need to iterate to the leaf node of first). The element discriptors themselves got extended by ConstructorDescriptor, MethodDescriptor, ParameterDescriptor and ReturnValueDescriptor.
  • Support for container injection in ConstraintValidator. Check out the new life cycle methods ValidatorFactory#close and ConstraintValidatorFactory#releaseInstance in this context.
  • Expose settings defined in XML in the Configuration API. Refer to the new interface javax.validation.ConfigurationSource, but be aware that there is a follow up issue (BVAL-292) as well.

The easiest way to find out more about these new interfaces and classes is to have a look at the Hibernate Validator test suite where you will find tests for all the mentioned new features.

There are more proposals which are still under active discussion. Feel free to contribute :-)

Given that this is an early draft there will be further changes to the API. For this reason Hibernate Validator 5.0.0.Alpha1 is not a production release. On the other hand, for integrators and tool developers it makes a lot of sense to have an early evaluation to see whether we are on the right track.

Enjoy!

Without further ado, Hibernate Validator 4.3.0.Final is available for download in the JBoss Maven Repository under the GAV org.hibernate:hibernate-validator:4.3.0.Final or via SourceForge.

The changelog for this version does not contain much, so let me summarize the most important changes of Hibernate Validator 4.3

  • The package structure got refactored to separate clearly between API, SPI and internal classes. Doing though we deprecated some classes. Make sure to migrate to the new types when upgrading to 4.3 read more
  • slf4j got replaced by JBoss Logging as the main logging framework read more
  • A bunch of new and improved constraints, e.g. MOD11, CNPJ, CPF and TituloEleitoral read more
  • A bunch of performance and quality improvements, in particular we addressed issues around metadata caching read more
  • The Hibernate Validator Annotation Processor can now be used without any additional dependencies which makes it setup easier read more
  • Hibernate Validator 4.3 requires now a Java 6 or 7 runtime

Please check also the Hibernate Validator Migration Guide.

Last but not least, thanks to everyone who was lending a helping hand during the development of Hibernate Validator 4.3 (in case you wanted to help, but missed out - why not helping by translating the documentation? Join the Hibernate Validator project on Zanata and get started...).

Enjoy!

P.S. In case you are waiting for a Validator release which aligns with the first draft of Bean Validation 1.1, have an eye on the JBoss snapshot repository. An initial hibernate-validator-5.0.0-SNAPSHOT won't be far off.

Hibernate Validator 4.3.0.Beta1

Posted by    |       |    Tagged as Hibernate Validator

Moving along the road to a Hibernate Validator 4.3 release I am happy to announce the release of Hibernate Validator 4.3.0.Beta1.

One of our foci this time around was to address existing caching issues. HV-479 addresses the problem that the constraint metadata for a given class would be cached in the so called BeanMetaDataManager without an appropriate eviction policy. In most cases this should not be a problem, but for long running applications with for example hot redeploys it could be. We resolved this issue by introducing SoftLimitMRUCache which has an upper bound for the cached metadata.

HV-564 is another caching related issue. Initially ConstraintValidator instances were only cached if they where created by the Hibernate Validator specific ConstraintValidatorFactoryImpl. Now caching occurs also for custom ConstraintValidatorFactorys.

Two other interesting issues are HV-563 and HV-517. The former allows you to reuse your Configuration instance and call Configuration#buildValidatorFactory() multiple times. The latter introduces the concept of ignoring annotations to the programmatic API. In the XML configuration it has always been possible to do something like this:

    <constraint-mappings
        xmlns="http://jboss.org/xml/ns/javax/validation/mapping"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.0.xsd">

        <bean class="my.package.MyClass" ignore-annotations="true">
        </bean>
    </constraint-mappings>
Via the programmatic API this is now possible via:
    // ...
    HibernateValidatorConfiguration configuration = ...
    ConstraintMapping mapping = configuration.createConstraintMapping();
    mapping.type( MyClass.class ).ignoreAllAnnotations();
    // ...
Of course ignoreAllAnnotations() is also available on the property level of the API.

Another important focus was on HV-561. This issue identifies the API methods which will change between Hibernate Validator 4.3 to 5 (as much as we can foresee this at the moment). Causes for these changes are Bean Validation 1.1 and the separation between API/SPI and internal packages. This has already been discussed in the previous release blog. Right now we have two new packages org.hibernate.validator.spi.group and org.hibernate.validator.spi.resourceloading containing DefaultGroupSequenceProvider and ResourceBundleLocator respectively. The old versions of these interfaces have been deprecated and will be removed in HV 5. On a side note, right now we have the following packages:

    org.hibernate.validator.cfg
    org.hibernate.validator.constraints
    org.hibernate.validator.group
    org.hibernate.validator.internal
    org.hibernate.validator.messageinterpolation
    org.hibernate.validator.method
    org.hibernate.validator.resourceloading
    org.hibernate.validator.spi
Would it make sense to have (by pushing cfg, constraints, group, messageinterpolation, method and resourceloading one level down):
    org.hibernate.validator.api
    org.hibernate.validator.internal
    org.hibernate.validator.spi
Obviously such a move would break much more client code than the current structure. Let us know what you think.

Last but not least, there are also some news from the Hibernate Validator Annotation Processor which can now be used without any additional dependencies (HV-457). This will make it easier to configure the processor within your build as well as IDE.

Hibernate Validator 4.3.0.Beta1 is available via the JBoss Maven Repository under the GAV org.hibernate:hibernate-validator:4.3.0.Beta1 or via SourceForge. The changelog is available here and make sure to check the Hibernate Validator Migration Guide as well.

Feedback is always welcome via the Validator Forum and the project issue tracker.

Enjoy!

A question which came up recently a lot was the question about the release plan for Hibernate Validator 4.3. It is time for an answer.

I used to say that Validator 4.3 will align with Bean Validation 1.1, incorporating any changes required for this specification update. Work on BV 1.1 is still in full swing and it is still time to raise your voice for your long missed validation feature. Check out beanvalidation.org for more information.

Back to Hibernate Validator though. Over the last few months we incorporated a bunch of useful changes and bug fixes into the code base. For example all string based ConstraintValidators work now on any subclass of CharSequence (HV-502) and the email validator now supports internationalized domain names (HV-472, Java 6 required). Or check out the new generic MOD11 constraint (HV-491) and its application in the new constraints CNPJ, CPF and TituloEleitoral (used for Brazilian individual taxpayer and voting registration numbers). We also have some performance improvements via HV-550 and HV-515.

As you can see quite a bunch of useful changes which we want to release as soon as possible. We also want to offer these improvements for users who don't want to upgrade to Bean Validation 1.1 right away (some of the expected changes will break backwards compatibility with Hibernate Validator 4.2). For this reason we just released Hibernate Validator 4.3.0.Alpha1 with the plan to move to a final release as fast as possible. Two more issues are worth mentioning though: HV-481 and HV-484. The former is the switch to JBoss Logging and the latter is the start of a package refactoring which will (once completed) introduce a clear separation between API/SPI and internal parts on a package level. This change is in accordance with the changes already introduced by the other Hibernate projects. Have a look at the Hibernate Validator Migration Guide to see what these changes imply.

Hibernate Validator 4.3.0.Alpha1 is available via the JBoss Maven Repository under the GAV org.hibernate:hibernate-validator:4.3.0.Alpha1 or via SourceForge. The changelog is available here. Feedback is welcome via the Validator Forum and the issue tracker.

As a result, Hibernate Validator 5 will become the reference implementation of Bean Validation 1.1.

Thanks to all the people suggesting features and reporting bugs. Special thanks to George Gastaldi, Kevin Pollet and Gunnar Morling for your continuous commitment. You guys rock!

Enjoy!

So it's official Bean Validation 1.1 has started. It has been voted yes by the JCP expert committee yesterday.

I must admit I'm quite furious about Mark Little, the Red Hat representative and my boss, for forgetting to vote on the ballot. But provided he went on vacations last Friday and has a lot on his plate, I forgive him. You owe me though :)

More seriously, Red Hat is committed to make Bean Validation 1.1 a success and I will spend the next couple of days gathering the expert group members to get started as quickly as possible.

In the mean time and to celebrate, have a look at the official beanvalidation.org website. The idea behind the website are simple:

  • execute on the promise to run the spec in an open fashion
  • offer regular updates on the work in progress (see the news section)
  • a one time shop for everything Bean Validation related

There are several ways for you to participate in the process. From joining the development mailing list to joining the expert group full blown. Check out the contribution page.

You might have heard the news: JBoss AS 7 is out :) What does it mean from an Hibernate user perspective?

Before we go that way and if you are in a hurry Pete has written a few getting started guides covering JPA in JBoss AS 7. You might be interested.

Back to the subject: JBoss AS 7 and Hibernate.

Hibernate Core

First of all, JBoss AS 7 comes with Hibernate Core 4. This essentially means that AS 7 will be using the new foundational grounds for Hibernate Core. Hibernate Core 4 comes with many internal changes:

  • A new ServiceRegistry interface: many pieces of Hibernate are now service based and many contracts have been enhanced (like connections and second level caches)
  • A MetadataSources interface: instead of mixing configuration and mapping like the Configuration class was doing, we have now split the concerns and lifecycles
  • A package refactoring splitting classes into api, spi and internals: if your application depends on internals, you know you might get burnt by a minor/micro update
  • A new class loader service (see below)
  • Better logging with consistent error id (our goal is to build an error-id to solution database somewhere over time)
  • A move to Git and GitHub for version control: hopefully this is speeding up community contribution integration

Multi-tenancy

We have also introduced some new features, the most interesting definitely being multi-tenancy (see also here).

New classloader service

Why?

Historically, Hibernate relied on standard class-loading paradigms that targeted JSE and JEE deployment environments. However, with the growth of OSGi and other modular systems like JBoss AS 7, those same approaches no longer always work. So Hibernate needed a new approach that would allow it operate in all possible deployment environments.

How?

In Hibernate 4 we leverage the ServiceRegistry to define a pluggable service for providing interaction with the class-loading of the semantics of the environment in which Hibernate will be run. Specifically, the idea is to allow external entities (the user, the environment developers, etc) to define and plug in a custom scheme for class path interactions. For example, an OSGi container could choose to provide Hibernate (either directly or as its JPA provider) and install a custom service for class loader interactions to override the default one.

Hibernate Core in AS 7

JBoss AS 7 integrates with Hibernate 4.0.0.Beta1, to provide both the EE container managed JPA features and application managed access as well. The AS7 JPA subsystem integrates with Hibernate via the JPA specification SPI interfaces. In earlier releases of JBoss AS, JPA integration code was part of the EJB3 container (reflecting the evolution from EJB entity beans). Moving the JPA integration code into its own subsystem helps simplify the code and makes it easier to make changes.

Quick second-level cache tip

Enabling the (Infinispan) second level cache should be as simple as including the following in your persistence.xml file:

  <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
  <properties>
    <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate"/>
    <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/>
  </properties>

I (aka Scott Marlow) would like to thank the following people for contributing to the JBoss AS7 JPA subsystem:

  • Stuart Douglas for contributing to the JPA subsystem.
  • Steve Ebersole for contributing to the JPA subsystem (especially Hibernate 4.0 integration).
  • Jaikiran Pai for contributing to the JPA subsystem and answering an amazing number of questions in the forums (JPA + hundreds of other topics).
  • Emmanuel Bernard for answering my never ending JPA 2.0 specification questions.
  • Carlo de Wolf for answering my questions about the EJB3 subsystem (which the new code is based on).

What is next

Improving support for applications that use a different version of Hibernate than is packaged with JBoss AS 7. The plan is to let users deploy the Hibernate jars as well as a hibernate-jbossas7 integration jar. The integration jar will be tailored to the specific couple of Hibernate / JBoss AS version (or families of).

To be clear, Hibernate native applications can already include their own version of Hibernate in JBoss AS 7 simply by including the jar in their deployment. But we want JPA applications to benefit from this enhancement as well. Because it involves specification classes, this requires a bit more work.

We will also include additional tuning options to disable some of the JPA integration (ie prevent the container from starting the persistence unit).

Hibernate Validator and Bean Validation

What's new in AS7 in relation to Bean Validation? The short answer - nothing. It was already awesome ;) The initial version - AS 7.0 - ships with Hibernate Validator 4.1.0.Final. This is the same Validator version as in AS 6 so no change there.

The long answer is that Hibernate Validator 4.2.0.Final merely missed the AS 7.0 release train and an upgrade is planned at the latest in AS 7.1. What will the update mean for AS users? Besides the usual bug fixes and performance improvements, the biggest new feature is the implementation of appendix C of the Bean Validation specification: method level validation.

With this API a design by contract approach is possible which can already be seen in action in the Seam Validation module. Another new feature is the ability to combine the composing constraints with AND and OR operators. There is also a fail fast mode in which validation stops on the first validation error and a new message interpolator which is able to interpolate the validated value.

As you can see AS 7.0 is just the beginning. More is to come in the coming releases...

Hibernate Search

We are working on Hibernate Search 4 which will be compatible with Hibernate Core 4. As a matter of fact, we have already published a compatible version via a Maven SNAPSHOT but expect a first alpha release soon.

Hibernate Search 4 is our chance to fix mistakes from the past. To be honest, the codebase and concepts have aged quite well despite the massive feature shifts we have done in Hibernate Search. Anyways, we are doing some changes including splitting API/SPI/implementations to help people discover when they use a class that is subject to change.

We are also working on a new per index manager to better use some of the new features and design changes of Lucene. This will give you more flexibility on how to index data on a per entity level (sync/async etc).

And remember, go try the blazingly fast, lightweight, modular, hot and incremental deployable, elegantly administrable, domain manageable, first class best of breed JBoss Application Server 7

Happy code/fast deploy/test cycles :)

Steve, Hardy, Scott Marlow and Emmanuel

Hibernate Validator 4.2.0.CR1

Posted by    |       |    Tagged as Bean Validation Hibernate Validator

Hibernate Validator 4.2.0.CR1 is finally ready for download via the JBoss Maven Repository or SourceForge. We promise you won't have to wait so long for 4.2.0.Final. In total we addressed 28 issues. Most of the issues where minor bug fixes, documentation and code refactorings. Thanks you everyone providing bug reports and helping us to make Validator even better :-)

The biggest change is the ability to now also configure method level validation programmatically. To implement this in an unambiguous way we had to make yet some more changes to the programmatic API. Remember how the programmatic API looked like in Beta2? Here is an example:

ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Car.class )
    .property( "manufacturer", FIELD )
        .constraint( NotNullDef.class )
    .property( "licensePlate", FIELD )
        .constraint( NotNullDef.class )
        .constraint( SizeDef.class )
            .min( 2 )
            .max( 14 )
    .property( "seatCount", FIELD )
        .constraint( MinDef.class )
            .value ( 2 )
.type( RentalCar.class )
    .property( "rentalStation", METHOD)
        .constraint( NotNullDef.class ); 

With the CR1 API the same example looks like:

ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Car.class )
    .property( "manufacturer", FIELD )
        .constraint( new NotNullDef() )
    .property( "licensePlate", FIELD )
        .constraint( new NotNullDef() )
        .constraint( new SizeDef()
            .min( 2 )
            .max( 14 ) )
    .property( "seatCount", FIELD )
        .constraint( new MinDef()
            .value ( 2 ) )
.type( RentalCar.class )
    .property( "rentalStation", METHOD )
        .constraint( new NotNullDef() ); 

As you can see the difference is that you now have to instantiate the definition classes. That's all. Not too bad, right? Programmatic method level validation looks like this:

ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Car.class )
    .method( "drive", String.class, Integer.class )
        .parameter( 0 )
            .constraint( new NotNullDef() )
            .constraint( new MinDef().value ( 1 ) )
        .parameter( 1 )
            .constraint( new NotNullDef() )
        .returnValue()
            .constraint( new NotNullDef() )
    .method( "check" )
        .returnValue()
            .constraint( new NotNullDef() );   

You find the full change log for this release here. Please provide feedback via the Validator Forum and the Jira issue tracker.

Thanks to Gunnar and Kevin to once more were driving most of the work.

Enjoy!

P.S. If you have any opinion what should go into Bean Validation 1.1 let us know!

Hibernate Validator 4.2.0.Beta2

Posted by    |       |    Tagged as Bean Validation Hibernate Validator

Hibernate Validator 4.2.0.Beta2 is bottled up and ready for consumption via the JBoss Maven Repository or SourceForge.

Since Beta1 we have been focusing on method level validation details and bug fixes. One important issue in this regard is HV-421 which defines the behavior of parameter constraint validation. Generally a logical AND is used to combine all constraints defined within a class hierarchy on a given field or method. Doing the same for method parameter constraints, however, causes ambiguities with the definition of Programming by contract where subtypes may only weaken preconditions defined by supertypes. In order to support this one would have to combine all parameter constraints within a hierarchy using an OR. A conservative alternative (the one we chose for this release) is to prohibit multiple parameter constraints on the same parameter within a class hierarchy. HV-421 discusses in more detail. We are very interested in feedback on this.

Another method level validation related feature is the extension of the meta data API (HV-440). We introduced three more interfaces TypeDescriptor, MethodDescriptor and ParameterDescriptor which you can all find in the org.hibernate.validator.method.metadata package. Here is an usage example:

 MethodValidator validator = Validation.byProvider( HibernateValidator.class )
    .configure()
    .buildValidatorFactory()
    .getValidator()
    .unwrap( MethodValidator.class );

TypeDescriptor typeDescriptor = validator.getConstraintsForType( clazz );
...
Set<MethodDescriptor> constrainedMethods = descriptor.getConstrainedMethods();
...
List<ParameterDescriptor> parameterConstraints = methodDescriptor.getParameterConstraints();
ParameterDescriptor parameterDescriptor = parameterConstraints.get( 0 );
assertTrue( parameterDescriptor.hasConstraints() );
...
Note: MethodValidator.validateParameters was renamed into MethodValidator.validateAllParameters (HV-415).

To mention at least one method level validation unrelated feature - Hibernate Validator has now a fail fast option. When enabled, validation will terminate on the first validation error. This could be interesting for large object graph validation. You can enable the fail fast flag for example via:

ValidatorFactory factory = Validation.byProvider( HibernateValidator.class )
                             .configure()
                             .failFast( true )
                             .buildValidatorFactory();
You find the full change log for this release here. Please provide feedback via the Validator Forum and the Jira issue tracker.

Enjoy!

P.S. For all the Seam people out there. Gunnar started a new Seam 3 module called SeamValidation which offers amongst other a CDI extension for method level validation. Check it out!

P.P.S. Make sure to also provide feedback on what we should include into Bean Validation 1.1

Vote for Pedro

Posted by    |       |    Tagged as Bean Validation Hibernate Validator

Well not really ;)

We have talked about Gunnar and Kevin that have and are still doing an awesome job on Hibernate Validator, especially for the last release and the current one in development. Please consider voting for them for the JBoss.org recognition awards.

Gunnar Morling is nominated in the:

The new method validation feature is all his for example.

And Kevin Pollet is nominated in the:

He fixed many bugs but also added some nice cool features like Joda-time support.

Yyou probably don't know it yet but Hibernate Core and Hibernate Validator source code is now on Git and Hibernate Search and co will likely follow very soon. There are various reasons for the move but to summarize it, life was not bad under SVN but it's really great under Git.

Getting Hibernate sources

The public reference Git repository is hosted at GitHub. We are not married to GitHub but so far, we really like the infrastructure they offer. Kudos to them! In any case moving is one clone away. That tends to keep services like that on their toes.

Hibernate Core is here while Hibernate Validator is there.

Contributing

If you want to contribute a fix or new feature, either:

  • use the GitHub fork capability: clone, work on a branch, fork the repo on GitHub (fork button), push the work there and trigger a pull request (pull request button). Also see http://help.github.com/forking and http://help.github.com/pull-requests
  • use the pure Git approach: clone, work on a branch, push to a public fork repo hosted somewhere, trigger a pull request git pull-request
  • provide a good old patch file: clone the repo, create a patch with git format-patch or diff and attach the patch file to JIRA

Our preference is GitHub over pure Git over patches:

  • GitHub lets us comment on your changes in a fine grained way
  • Git generally leads to more small commits that are easier to follow
  • a big fat patch of 100k is always depressing and can't be updated easliy

If you still want to do it the old way a provide a patch file, that's ok too.

Various tips on Git

While in no way comprehensive, here are a collection of useful tips when using Git.

Read a book on it

The time will be worth it. I particularly enjoyed Pro Git. It's an awesome book and very practical. It has a free html and epub version (buying the tree version is recommended to repay the author).

Cloning

Prefer the git protocol when cloning over http (so say the experts). At the very least that will be much faster. cloning the repo from GitHub took me less than 3 minutes.

#for people with read/write access
git clone git@github.com:hibernate/hibernate-core.git

#for people with read-only access
git clone git://github.com/hibernate/hibernate-core.git

This will create a remote link named origin. I usually tend to rename it to reflect what it really is.

git remote rename origin core-on-github

Note that you can attach more than one remote repository to your local repository

git clone git://github.com/hibernate/hibernate-core.git
git remote rename origin ref-core-github
git remote add manu-core-github git@github.com:emmanuelbernard/hibernate-core.git
git fetch manu-core-github

Pushing and pulling

To initially get a copy of a remote branch locally, do

git checkout -b 3.6 origin/3.6

When pulling a branch, it's best to keep the same name between the origin repo and your clone. Many syntax have shortcuts in this situation (are you listening Hardy? ;) ). You can then do

git push origin master

If you happen to have renamed the branch master to say local-master locally, do

git push origin local-master:master

To delete a branch on a remote repository, you push an empty one

git push origin :branch-to-remove

Branches

Always work on a topic branch and merge your work when you are done.

git checkout master
git checkout -b HHH-XXX
#hack commit hack commit

Don't forget to pull from your master and rebase this topic branch before proposing request pull.

There are many advantages to this, one of them being that you can work on many different things in parallel and sync them with the reference master easily.

Likewise if you want to share a work with somebody from the Hibernate team, push to the public repo and define the pull request of your topic branch. Make sure your topic branch is above the most recent master.

Commits

Prefer small commits, they will be more readable and will very unlikely fail on merge.

Write good comments (one short line including the issue number at stake and a summary, followed by a blank line and a more detailed explanation if needed.

HHH-XXX Fix NPE on persist

Fix stupid bug by Gavin that lead to a NPE when persisting objects with components

Merge or rebase

It's a debate, but here is my take on it.

  • Primitive 0: DO NOT rebase a branch that you have shared publicly (unless you know people won't use it or you wish them harm).
  • Primitive 1: Prefer rebase over merge assuming it does not break Primitive 0

This is particularly sensible when you trigger a pull request: rebase atop the branch you are branching of (master usually). Your work will be easier to read and integrate.

Rebase put changes from the branch you forked (say master) below the new commits you have done (say HHH-XXX) and thus keep the history linear.

git checkout HHH-XXX
git rebase master

While we are at rebasing, you can rewrite your commit history to clean comments or merge some commits together (aka squashing)

git rebase -i HEAD~6 (go back 6 commits in time)

Backporting: cherry-picking

Git made backporting fun.

Say you have done some commits on master and the sha1 of the commits are ae397d... and 87ab342...

You can apply them on an older branch very easily.

git checkout 3.5
git cherry-pick ae397d
git cherry-pick 87ab34

Bam, you're done. Now did I tell you to do small commits? That's also for the backporters.

Aliases and configuration

Once you're fed up with typing longish command lines, use aliases. I've put a copy of my ~/.gitconfig file in case people want to copy some things including aliases (see below)

~/.gitconfig
[user]
     name = Redacted
     email = redacted@redacted.com
     signingkey = id_key.pub
[core]
     editor = open -nW -a Smultron
[merge]
     tool = opendiff
[color]
     ui = auto
[color "branch"]
     current = yellow reverse
     local = yellow
     remote = green
[color "diff"]
     meta = yellow bold
     frag = magenta bold
     old = red bold
     new = green bold
[color "status"]
     added = yellow
     changed = green
     untracked = cyan
[github]
     user = redacted
     token = redacted
[alias]
     co = checkout
     undo = reset --hard
     cb = checkout -b
     br = branch
     cp = cherry-pick

Tools

If you use Mac OS X, GitX is a fantastic tool. In particular, you can very easily play with interactive staging and commit only some parts of a file in a couple of clicks. A typical use case is to separate the commit of a typo from the commit of a core feature. Some people like the built-in GitK GUI.

Command completion support via git-completion.bash is pretty good if you are command shell type person. The script is available in the Git project sources and in other places (including Fedora). Pro Git has some more information on it.

Various

You can also read this blog entry that was some more info for people moving from SVN to Git.

This entry is too long already, feel free to add your tips in the comments.

back to top