]> Cypherpunks.ru repositories - nncp.git/blob - doc/integration/git.texi
a159cf885135b772fce9250ea88248d2c21c6cbe
[nncp.git] / doc / integration / git.texi
1 @node Git
2 @section Integration with Git
3
4 @url{https://git-scm.com/, Git} version control system already has all
5 necessary tools for store-and-forward networking.
6 @url{https://git-scm.com/docs/git-bundle, git-bundle} command is
7 everything you need.
8
9 Use it to create bundles containing all required blobs/trees/commits and tags:
10
11 @example
12 $ git bundle create repo-initial.bundle master --tags --branches
13 $ git tag -f last-bundle
14 $ nncp-file repo-initial.bundle remote.node:repo-$(date % '+%Y%M%d%H%m%S').bundle
15 @end example
16
17 Do usual working with the Git: commit, add, branch, checkout, etc. When
18 you decide to queue your changes for sending, create diff-ed bundle and
19 transfer them:
20
21 @example
22 $ git bundle create repo-$(date '+%Y%M%d%H%m%S').bundle last-bundle..master
23 or maybe
24 $ git bundle create repo-$(date '+%Y%M%d').bundle --since=10.days master
25 @end example
26
27 Received bundle on remote machine acts like usual remote:
28
29 @example
30 $ git clone -b master repo-XXX.bundle
31 @end example
32
33 overwrite @file{repo.bundle} file with newer bundles you retrieve and
34 fetch all required branches and commits:
35
36 @example
37 $ git pull # assuming that origin remote points to repo.bundle
38 $ git fetch repo.bundle master:localRef
39 $ git ls-remote repo.bundle
40 @end example
41
42 Bundles are also useful when cloning huge repositories (like Linux has).
43 Git's native protocol does not support any kind of interrupted download
44 resuming, so you will start from the beginning if connection is lost.
45 Bundles, being an ordinary files, can be downloaded with native
46 HTTP/FTP/NNCP resuming capabilities. After you fetch repository via the
47 bundle, you can add an ordinary @file{git://} remote and fetch the
48 difference.
49
50 Also you can find the following exec-handler useful:
51
52 @verbatiminclude git-bundler.sh
53
54 And it allows you to request for bundles like that:
55 @code{echo some-old-commit..master | nncp-exec REMOTE bundler REPONAME}.