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 | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame^] | 12 | 'git bundle' create [-q | --quiet | --progress | --all-progress] [--all-progress-implied] <file> <git-rev-list-args> |
| 13 | 'git bundle' verify [-q | --quiet] <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 | f85ef63 | 2016-02-17 22:31:06 | [diff] [blame] | 23 | ssh, 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 | |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame^] | 36 | create [options] <file> <git-rev-list-args>:: |
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 | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame^] | 39 | 'options' contains the options specific to the 'git bundle create' |
| 40 | subcommand. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 41 | |
| 42 | verify <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 43 | Used to check that a bundle file is valid and will apply |
| 44 | cleanly to the current repository. This includes checks on the |
| 45 | bundle format itself as well as checking that the prerequisite |
| 46 | commits exist and are fully linked in the current repository. |
| 47 | 'git bundle' prints a list of missing commits, if any, and exits |
| 48 | with a non-zero status. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 49 | |
| 50 | list-heads <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 51 | Lists the references defined in the bundle. If followed by a |
| 52 | list of references, only references matching those given are |
| 53 | printed out. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 54 | |
| 55 | unbundle <file>:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 56 | Passes the objects in the bundle to 'git index-pack' |
| 57 | for storage in the repository, then prints the names of all |
| 58 | defined references. If a list of references is given, only |
| 59 | references matching those in the list are printed. This command is |
| 60 | really plumbing, intended to be called only by 'git fetch'. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 61 | |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 62 | <git-rev-list-args>:: |
| 63 | A list of arguments, acceptable to 'git rev-parse' and |
Junio C Hamano | 7165bf7 | 2011-01-04 22:06:18 | [diff] [blame] | 64 | 'git rev-list' (and containing a named ref, see SPECIFYING REFERENCES |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 65 | below), that specifies the specific objects and references |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 66 | to transport. For example, `master~10..master` causes the |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 67 | current master reference to be packaged along with all objects |
| 68 | added since its 10th ancestor commit. There is no explicit |
| 69 | limit to the number of references and objects that may be |
| 70 | packaged. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 71 | |
| 72 | |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 73 | [<refname>...]:: |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 74 | A list of references used to limit the references reported as |
| 75 | available. This is principally of use to 'git fetch', which |
| 76 | expects to receive only those references asked for and not |
| 77 | necessarily everything in the pack (in this case, 'git bundle' acts |
| 78 | like 'git fetch-pack'). |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 79 | |
Junio C Hamano | 8ef91f3 | 2019-12-01 22:58:27 | [diff] [blame^] | 80 | --progress:: |
| 81 | Progress status is reported on the standard error stream |
| 82 | by default when it is attached to a terminal, unless -q |
| 83 | is specified. This flag forces progress status even if |
| 84 | the standard error stream is not directed to a terminal. |
| 85 | |
| 86 | --all-progress:: |
| 87 | When --stdout is specified then progress report is |
| 88 | displayed during the object count and compression phases |
| 89 | but inhibited during the write-out phase. The reason is |
| 90 | that in some cases the output stream is directly linked |
| 91 | to another command which may wish to display progress |
| 92 | status of its own as it processes incoming pack data. |
| 93 | This flag is like --progress except that it forces progress |
| 94 | report for the write-out phase as well even if --stdout is |
| 95 | used. |
| 96 | |
| 97 | --all-progress-implied:: |
| 98 | This is used to imply --all-progress whenever progress display |
| 99 | is activated. Unlike --all-progress this flag doesn't actually |
| 100 | force any progress display by itself. |
| 101 | |
| 102 | -q:: |
| 103 | --quiet:: |
| 104 | This flag makes the command not to report its progress |
| 105 | on the standard error stream. |
| 106 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 107 | SPECIFYING REFERENCES |
| 108 | --------------------- |
| 109 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 110 | 'git bundle' will only package references that are shown by |
| 111 | 'git show-ref': this includes heads, tags, and remote heads. References |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 112 | such as `master~1` cannot be packaged, but are perfectly suitable for |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 113 | defining the basis. More than one reference may be packaged, and more |
| 114 | than one basis can be specified. The objects packaged are those not |
| 115 | contained in the union of the given bases. Each basis can be |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 116 | specified explicitly (e.g. `^master~10`), or implicitly (e.g. |
| 117 | `master~10..master`, `--since=10.days.ago master`). |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 118 | |
| 119 | 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] | 120 | It is okay to err on the side of caution, causing the bundle file |
| 121 | to contain objects already in the destination, as these are ignored |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 122 | when unpacking at the destination. |
| 123 | |
Junio C Hamano | b9d9d90 | 2018-05-23 07:07:42 | [diff] [blame] | 124 | EXAMPLES |
| 125 | -------- |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 126 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 127 | Assume you want to transfer the history from a repository R1 on machine A |
| 128 | to another repository R2 on machine B. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 129 | For whatever reason, direct connection between A and B is not allowed, |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 130 | but we can move data from A to B via some mechanism (CD, email, etc.). |
| 131 | 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] | 132 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 133 | To bootstrap the process, you can first create a bundle that does not have |
| 134 | any basis. You can use a tag to remember up to what commit you last |
| 135 | processed, in order to make it easy to later update the other repository |
| 136 | with an incremental bundle: |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 137 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 138 | ---------------- |
| 139 | machineA$ cd R1 |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 140 | machineA$ git bundle create file.bundle master |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 141 | machineA$ git tag -f lastR2bundle master |
| 142 | ---------------- |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 143 | |
Junio C Hamano | 6bdcc7d | 2013-01-09 00:15:42 | [diff] [blame] | 144 | Then you transfer file.bundle to the target machine B. Because this |
| 145 | bundle does not require any existing object to be extracted, you can |
| 146 | create a new repository on machine B by cloning from it: |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 147 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 148 | ---------------- |
Junio C Hamano | 6bdcc7d | 2013-01-09 00:15:42 | [diff] [blame] | 149 | machineB$ git clone -b master /home/me/tmp/file.bundle R2 |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 150 | ---------------- |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 151 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 152 | This will define a remote called "origin" in the resulting repository that |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 153 | 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] | 154 | have an entry like this: |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 155 | |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 156 | ------------------------ |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 157 | [remote "origin"] |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 158 | url = /home/me/tmp/file.bundle |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 159 | fetch = refs/heads/*:refs/remotes/origin/* |
Junio C Hamano | 601f3e5 | 2008-02-25 08:40:42 | [diff] [blame] | 160 | ------------------------ |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 161 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 162 | To update the resulting mine.git repository, you can fetch or pull after |
| 163 | replacing the bundle stored at /home/me/tmp/file.bundle with incremental |
| 164 | updates. |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 165 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 166 | After working some more in the original repository, you can create an |
| 167 | incremental bundle to update the other repository: |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 168 | |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 169 | ---------------- |
| 170 | machineA$ cd R1 |
Junio C Hamano | 6116912 | 2009-02-09 18:05:49 | [diff] [blame] | 171 | machineA$ git bundle create file.bundle lastR2bundle..master |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 172 | machineA$ git tag -f lastR2bundle master |
| 173 | ---------------- |
| 174 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 175 | You then transfer the bundle to the other machine to replace |
| 176 | /home/me/tmp/file.bundle, and pull from it. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 177 | |
| 178 | ---------------- |
| 179 | machineB$ cd R2 |
| 180 | machineB$ git pull |
| 181 | ---------------- |
| 182 | |
| 183 | If you know up to what commit the intended recipient repository should |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 184 | have the necessary objects, you can use that knowledge to specify the |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 185 | 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] | 186 | in the resulting bundle. The previous example used the lastR2bundle tag |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 187 | 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] | 188 | the linkgit:git-log[1] command. Here are more examples: |
| 189 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 190 | You can use a tag that is present in both: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 191 | |
| 192 | ---------------- |
| 193 | $ git bundle create mybundle v1.0.0..master |
| 194 | ---------------- |
| 195 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 196 | You can use a basis based on time: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 197 | |
| 198 | ---------------- |
| 199 | $ git bundle create mybundle --since=10.days master |
| 200 | ---------------- |
| 201 | |
Junio C Hamano | 1de7572 | 2009-03-26 08:39:38 | [diff] [blame] | 202 | You can use the number of commits: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 203 | |
| 204 | ---------------- |
| 205 | $ git bundle create mybundle -10 master |
| 206 | ---------------- |
| 207 | |
| 208 | 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] | 209 | that was created with a basis: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 210 | |
| 211 | ---------------- |
| 212 | $ git bundle verify mybundle |
| 213 | ---------------- |
| 214 | |
| 215 | 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] | 216 | bundle and will error out if you do not have them. |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 217 | |
| 218 | 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] | 219 | regular repository which it fetches or pulls from. You can, for example, map |
| 220 | references when fetching: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 221 | |
| 222 | ---------------- |
| 223 | $ git fetch mybundle master:localRef |
| 224 | ---------------- |
| 225 | |
Junio C Hamano | 2db3e75 | 2010-09-03 21:33:06 | [diff] [blame] | 226 | You can also see what references it offers: |
Junio C Hamano | a3bb6eb | 2009-02-05 01:26:33 | [diff] [blame] | 227 | |
| 228 | ---------------- |
| 229 | $ git ls-remote mybundle |
| 230 | ---------------- |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 231 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 232 | GIT |
| 233 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 234 | Part of the linkgit:git[1] suite |