Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 1 | git-bundle(1) |
| 2 | ============= |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-bundle - Move objects and refs by archive |
| 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
Junio C Hamano | a9b8d24 | 2007-05-19 04:51:55 | [diff] [blame] | 11 | [verse] |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 12 | 'git bundle' create <file> <git-rev-list-args> |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 13 | 'git bundle' verify <file> |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 14 | 'git bundle' list-heads <file> [<refname>...] |
| 15 | 'git bundle' unbundle <file> [<refname>...] |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 16 | |
| 17 | DESCRIPTION |
| 18 | ----------- |
| 19 | |
| 20 | Some workflows require that one or more branches of development on one |
| 21 | machine be replicated on another machine, but the two machines cannot |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 22 | be directly connected, and therefore the interactive Git protocols (git, |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 23 | ssh, rsync, http) cannot be used. This command provides support for |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 24 | 'git fetch' and 'git pull' to operate by packaging objects and references |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 25 | in an archive at the originating machine, then importing those into |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 26 | another repository using 'git fetch' and 'git pull' |
Junio C Hamano | 2bd8a74 | 2009-12-01 21:16:59 | [diff] [blame] | 27 | after moving the archive by some means (e.g., by sneakernet). As no |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 28 | direct connection between the repositories exists, the user must specify a |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 29 | basis for the bundle that is held by the destination repository: the |
| 30 | bundle assumes that all objects in the basis are already in the |
| 31 | destination repository. |
| 32 | |
| 33 | OPTIONS |
| 34 | ------- |
| 35 | |
| 36 | create <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 37 | Used to create a bundle named 'file'. This requires the |
| 38 | 'git-rev-list-args' arguments to define the bundle contents. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 39 | |
| 40 | verify <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 41 | Used to check that a bundle file is valid and will apply |
| 42 | cleanly to the current repository. This includes checks on the |
| 43 | bundle format itself as well as checking that the prerequisite |
| 44 | commits exist and are fully linked in the current repository. |
| 45 | 'git bundle' prints a list of missing commits, if any, and exits |
| 46 | with a non-zero status. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 47 | |
| 48 | list-heads <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 49 | Lists the references defined in the bundle. If followed by a |
| 50 | list of references, only references matching those given are |
| 51 | printed out. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 52 | |
| 53 | unbundle <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 54 | Passes the objects in the bundle to 'git index-pack' |
| 55 | for storage in the repository, then prints the names of all |
| 56 | defined references. If a list of references is given, only |
| 57 | references matching those in the list are printed. This command is |
| 58 | really plumbing, intended to be called only by 'git fetch'. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 59 | |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 60 | <git-rev-list-args>:: |
| 61 | A list of arguments, acceptable to 'git rev-parse' and |
Junio C Hamano | 7165bf7 | 2011-01-04 22:06:18 | [diff] [blame] | 62 | 'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 63 | below), that specifies the specific objects and references |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 64 | to transport. For example, `master~10..master` causes the |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 65 | current master reference to be packaged along with all objects |
| 66 | added since its 10th ancestor commit. There is no explicit |
| 67 | limit to the number of references and objects that may be |
| 68 | packaged. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 69 | |
| 70 | |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 71 | [<refname>...]:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 72 | A list of references used to limit the references reported as |
| 73 | available. This is principally of use to 'git fetch', which |
| 74 | expects to receive only those references asked for and not |
| 75 | necessarily everything in the pack (in this case, 'git bundle' acts |
| 76 | like 'git fetch-pack'). |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 77 | |
| 78 | SPECIFYING REFERENCES |
| 79 | --------------------- |
| 80 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 81 | 'git bundle' will only package references that are shown by |
| 82 | 'git show-ref': this includes heads, tags, and remote heads. References |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 83 | such as `master~1` cannot be packaged, but are perfectly suitable for |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 84 | defining the basis. More than one reference may be packaged, and more |
| 85 | than one basis can be specified. The objects packaged are those not |
| 86 | contained in the union of the given bases. Each basis can be |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 87 | specified explicitly (e.g. `^master~10`), or implicitly (e.g. |
| 88 | `master~10..master`, `--since=10.days.ago master`). |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 89 | |
| 90 | It is very important that the basis used be held by the destination. |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 91 | It is okay to err on the side of caution, causing the bundle file |
| 92 | to contain objects already in the destination, as these are ignored |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 93 | when unpacking at the destination. |
| 94 | |
| 95 | EXAMPLE |
| 96 | ------- |
| 97 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 98 | Assume you want to transfer the history from a repository R1 on machine A |
| 99 | to another repository R2 on machine B. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 100 | For whatever reason, direct connection between A and B is not allowed, |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 101 | but we can move data from A to B via some mechanism (CD, email, etc.). |
| 102 | We want to update R2 with development made on the branch master in R1. |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 103 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 104 | To bootstrap the process, you can first create a bundle that does not have |
| 105 | any basis. You can use a tag to remember up to what commit you last |
| 106 | processed, in order to make it easy to later update the other repository |
| 107 | with an incremental bundle: |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 108 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 109 | ---------------- |
| 110 | machineA$ cd R1 |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 111 | machineA$ git bundle create file.bundle master |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 112 | machineA$ git tag -f lastR2bundle master |
| 113 | ---------------- |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 114 | |
Junio C Hamano | 6bdcc7d | 2013-01-09 00:15:42 | [diff] [blame] | 115 | Then you transfer file.bundle to the target machine B. Because this |
| 116 | bundle does not require any existing object to be extracted, you can |
| 117 | create a new repository on machine B by cloning from it: |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 118 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 119 | ---------------- |
Junio C Hamano | 6bdcc7d | 2013-01-09 00:15:42 | [diff] [blame] | 120 | machineB$ git clone -b master /home/me/tmp/file.bundle R2 |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 121 | ---------------- |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 122 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 123 | This will define a remote called "origin" in the resulting repository that |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 124 | lets you fetch and pull from the bundle. The $GIT_DIR/config file in R2 will |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 125 | have an entry like this: |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 126 | |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 127 | ------------------------ |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 128 | [remote "origin"] |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 129 | url = /home/me/tmp/file.bundle |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 130 | fetch = refs/heads/*:refs/remotes/origin/* |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 131 | ------------------------ |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 132 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 133 | To update the resulting mine.git repository, you can fetch or pull after |
| 134 | replacing the bundle stored at /home/me/tmp/file.bundle with incremental |
| 135 | updates. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 136 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 137 | After working some more in the original repository, you can create an |
| 138 | incremental bundle to update the other repository: |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 139 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 140 | ---------------- |
| 141 | machineA$ cd R1 |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 142 | machineA$ git bundle create file.bundle lastR2bundle..master |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 143 | machineA$ git tag -f lastR2bundle master |
| 144 | ---------------- |
| 145 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 146 | You then transfer the bundle to the other machine to replace |
| 147 | /home/me/tmp/file.bundle, and pull from it. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 148 | |
| 149 | ---------------- |
| 150 | machineB$ cd R2 |
| 151 | machineB$ git pull |
| 152 | ---------------- |
| 153 | |
| 154 | If you know up to what commit the intended recipient repository should |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 155 | have the necessary objects, you can use that knowledge to specify the |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 156 | basis, giving a cut-off point to limit the revisions and objects that go |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 157 | in the resulting bundle. The previous example used the lastR2bundle tag |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 158 | for this purpose, but you can use any other options that you would give to |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 159 | the linkgit:git-log[1] command. Here are more examples: |
| 160 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 161 | You can use a tag that is present in both: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 162 | |
| 163 | ---------------- |
| 164 | $ git bundle create mybundle v1.0.0..master |
| 165 | ---------------- |
| 166 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 167 | You can use a basis based on time: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 168 | |
| 169 | ---------------- |
| 170 | $ git bundle create mybundle --since=10.days master |
| 171 | ---------------- |
| 172 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 173 | You can use the number of commits: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 174 | |
| 175 | ---------------- |
| 176 | $ git bundle create mybundle -10 master |
| 177 | ---------------- |
| 178 | |
| 179 | You can run `git-bundle verify` to see if you can extract from a bundle |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 180 | that was created with a basis: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 181 | |
| 182 | ---------------- |
| 183 | $ git bundle verify mybundle |
| 184 | ---------------- |
| 185 | |
| 186 | This will list what commits you must have in order to extract from the |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 187 | bundle and will error out if you do not have them. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 188 | |
| 189 | A bundle from a recipient repository's point of view is just like a |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 190 | regular repository which it fetches or pulls from. You can, for example, map |
| 191 | references when fetching: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 192 | |
| 193 | ---------------- |
| 194 | $ git fetch mybundle master:localRef |
| 195 | ---------------- |
| 196 | |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 197 | You can also see what references it offers: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 198 | |
| 199 | ---------------- |
| 200 | $ git ls-remote mybundle |
| 201 | ---------------- |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 202 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 203 | GIT |
| 204 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 205 | Part of the linkgit:git[1] suite |