@node Git
@cindex git integration
@pindex git-bundle
@section Integration with Git

@url{https://git-scm.com/, Git} version control system already has all
necessary tools for store-and-forward networking.
@url{https://git-scm.com/docs/git-bundle, git-bundle} command is
everything you need.

Use it to create bundles containing all required blobs/trees/commits and tags:

@example
$ git bundle create repo-initial.bundle master --tags --branches
$ git tag -f last-bundle
$ nncp-file repo-initial.bundle remote.node:repo-$(date % '+%Y%M%d%H%m%S').bundle
@end example

Do usual working with the Git: commit, add, branch, checkout, etc. When
you decide to queue your changes for sending, create diff-ed bundle and
transfer them:

@example
$ git bundle create repo-$(date '+%Y%M%d%H%m%S').bundle last-bundle..master
or maybe
$ git bundle create repo-$(date '+%Y%M%d').bundle --since=10.days master
@end example

Received bundle on remote machine acts like usual remote:

@example
$ git clone -b master repo-XXX.bundle
@end example

overwrite @file{repo.bundle} file with newer bundles you retrieve and
fetch all required branches and commits:

@example
$ git pull # assuming that origin remote points to repo.bundle
$ git fetch repo.bundle master:localRef
$ git ls-remote repo.bundle
@end example

Bundles are also useful when cloning huge repositories (like Linux has).
Git's native protocol does not support any kind of interrupted download
resuming, so you will start from the beginning if connection is lost.
Bundles, being an ordinary files, can be downloaded with native
HTTP/FTP/NNCP resuming capabilities. After you fetch repository via the
bundle, you can add an ordinary @file{git://} remote and fetch the
difference.

Also you can find the following exec-handler useful:

@verbatiminclude git-bundler.sh

And it allows you to request for bundles like that:
@code{echo some-old-commit..master | nncp-exec REMOTE bundler REPONAME}.
