Migrate git repositories

Recently I came across the task of migrating existing repositories from one gitlabs instance to another.

I could have generated a backup and restored it, however, I didn’t want to deal with any migration issues so I decided to simple push the existing repositories to a new remote.

Below is a shell scripts that clones existing git repositories and then push their refs to a new remote:



for (( i = 0 ; i < ${#old_name[@]} ; i=$i+1 ));
  echo -e "\n\nRepo $i"
  echo "old - $old"
  echo "new - $new"

  if [ ! -d "$old" ]; then
    echo -e "\nCloning repository $old..."

    git clone git@gitlabs.dev.cloud:clouddynamics/$old.git
    cd $old
    git remote rm origin
    git remote add origin git@gitlabs.cloud:cloud-dynamics/$new.git
    git push --all origin
    cd $cur_dir


the script above will not push all branches to the new remote.
if you want to migrate all branches run the following scripts as well:



for (( i = 0 ; i < ${#old_name[@]} ; i=$i+1 ));
  echo -e "\n\nRepo $i"
  echo "old - $old"
  cd $old
  echo -e "\nPushing branches from old to origin remote..."
  git remote add old git@gitlabs.dev.cloud:clouddynamics/$old.git
  git fetch old
  git push origin refs/remotes/old/*:refs/heads/*
  cd $cur_dir

Jackson overview

Recently I found the need to dig deeper and start getting a better grip on how jackson handles data parsing and manipulation. I always had some problems converting Jpa -> Date -> DateTime -> Json and back and forth, however, by plugin in some custom serializes/deserializers I always hacked my way around it.

Now that I’m starting to use Jongo I had to look at some features jackson provides to customize the mapping between mongo BasicDBObjects and POJOs

In the next few weeks I plan to write some blog posts show casing some cool features jackson offers.


Jackson overview

One thing to make clear is that the official project is now being maintained under FasterXML, not Codehaus.
Codehaus is a collaborative environment for building opensource projects, jackson moved away from codehaus is now under the FasterXML umbrella

The last released made under the codehaus banner was in July 14 2013, version 1.9.13,
Some differences between the old and new jackson are:

  • Maven build instead of Ant
  • Annotations carved out to a separate package (that this package depends on)
  • Java package is now com.fasterxml.jackson.core (instead of org.codehaus.jackson)

Main components

jackson-core – defines low-level streaming api, and includes JSON-specific implementations
The core package is where all the low level parser implementation is kept, some core classes that handle the raw json object creation are JsonReadContext and JsonWriteContext

More info can be found at their javadocs

jackson-annoations – contains standard jackson annotations
The annoations packages contains the definition of all the annoations used by jackson, 31 in total.
Some annoations worth noting are:

jackson-databind – implements data-binding and object serialization support on streaming packages

This is the package the handles most of the jackson parsing logic, classes like the ObjectMapper and SimpleModule are present in this packaged

The databind package bootstraps the annotations defined in the jackson-annotations package, one reason to separate the annoations from the databind package is to allow third party libraries to extend the utilize the annoations without having to include the whole databind package in its build.

Besides the main modules jackson also provides support for third party libraries, some of them are:

  • joda
  • hibernate
  • guava
  • hppc
  • jax-rs

Overall jackson is a stable library that provides solid data manipulation support for different data types in java. The way it is architecture it allows new types to be easily implemented and it also provides a rich feature api that developers can extend to fit different application needs.

One thing I would say is that the documentation about jackson is very fragmented, I usually like to go to a single page and get all the info I need about a project, with jackson I always find myself hoping around between sites to find the info I need. It might be fragmented due to the change from codehaus to fasterxml, but in any case I would really like to see some effort into making the library more presentable.

I know for sure that several applications use jackson and the library is rock solid, its web presence should reflect the same image.

I’ll give one example: Jongo

Jongo documentation is pretty well done, plus other useful links regarding the project are well organized. Jongo uses jackson as its based parser, maybe jackson could use jongo presentation as an inspiration?