Git 1.5.3 : submodule
Here’s another new functionality introduce in Git 1.5.3 : submodule.
Submodules allows you to manage subparts of a project in different git repositories and reference them in a “superproject” repository.
You can see it as an equivalent to Subversion “externals”.
A simple usage exemple (in your “superproject” root) :
git submodule add http://mygitdomain.tld/my_sub_project
git submodule init
git submodule update- This will add the remote my_sub_project as an entry in .gitmodules and a directory named my_sub_project in your “superproject”.
- Then initialize all modules added, this means add them to .git/config
- And finally clone and checkout the different modules in their respective directories (created by the
git submodule addcommand)
[Update – 2007/12/05]
I forgot to add you should not work directly with the “superproject” git repository besides adding more submodules.
You should clone the “superproject” git repository first and then the submodule part will be usable.
git clone superproject superprojectcloned
cd superprojectcloned
git submodule init
git submodule updateand work from “superprojectcloned” repository.
Then when you want to include the last versions of the submodules, issue :
git submodule status
git submodule update- status, gives you an overview of the submodules state.
- update, fetch the latest version and reference the sha1 associated.[…]
Git 1.5.3 : stash
I installed this monday Git 1.5.3 and discovered a new functionality I find worth sharing : stash.
Basically, stash grab your current uncommitted changes and put them away until you want to reapply them. Git documentation for git-stash lists two examples where this comes in handy :
- Pulling into a dirty tree
git pull does not work. Here come the stash, simply issue a git stash (or git-stash, with an optional description message as you can have multiple stashes), then git pull to include the upstream changes and finally git stash apply to re-integrate your latest stashed modifications.
- Interrupted workflow (this one talk to me so much)