开发者

git-bundle only some of the files in my repository

I have a library that I wrote for my app but now want to use it in all apps my company is going to write. The app and lib开发者_开发问答rary both live in a git repository (repository A) with history that I really would like to preserve. The library sits in it's own subfolder.

I also have a second repository (repository B) that contains some other shared code - this is used as a git-submodule in apps that we write.

I would like to take the libraries subfolder from repository A and place it into repository B without losing it's history.

I've looked at git-bundle but don't seem to be able to specify files, only branches.

I've also looked at copying the repository and removing the files I don't want (like this) but the libraries files started out with different names and in different folders so I'm just not sure how that would work.

Does anyone have any ideas of the best way that this could be done?


You're looking for git filter-branch. See this question and answer (be sure to note the additional section marked 'edit', too).


Note that, with Git 2.36 (Q2 2022, eleven years later), git bundle itself will support your use case: the bundle file format gets extended to allow a partial bundle, filtered by similar criteria you would give when making a partial/lazy clone.

See commit 86fdd94, commit 4f39eb0, commit f18b512, commit c4ea513, commit 105c6f1, commit f0d2f84, commit 3e0370a, commit 09d4a79, commit 7940941, commit ffaa137, commit 4a4c3f9, commit 1f52cdf (09 Mar 2022) by Derrick Stolee (derrickstolee).
See commit 4f33a63 (09 Mar 2022) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit 7391ecd, 21 Mar 2022)

bundle: create filtered bundles

Signed-off-by: Derrick Stolee

A previous change allowed Git to parse bundles with the 'filter' capability.
Now, teach Git to create bundles with this option.

Some rearranging of code is required to get the option parsing in the correct spot.
There are now two reasons why we might need capabilities (a new hash algorithm or an object filter) so that is pulled out into a place where we can check both at the same time.

The --filter option is parsed as part of setup_revisions(), but it expected the --objects flag, too.
That flag is somewhat implied by 'git bundle'(man) because it creates a pack-file walking objects, but there is also a walk that walks the revision range expecting only commits.
Make this parsing work by setting 'revs.tree_objects' and 'revs.blob_objects' before the call to setup_revisions().


And, still with Git 2.36 (Q2 2022):

See commit 5cb2827 (28 Mar 2022) by Ævar Arnfjörð Bjarmason (avar).
See commit 8ba221e, commit 017303e, commit 831ee25, commit 80f6de4, commit cc91044 (22 Mar 2022) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster -- in commit 3928e90, 04 Apr 2022)

bundle: move capabilities to end of 'verify'

Signed-off-by: Derrick Stolee

The 'filter' capability was added in 105c6f1 ("bundle: parse filter capability", 2022-03-09, Git v2.36.0-rc0 -- merge listed in batch #13), but was added in a strange place in the 'git bundle verify'(man) output.

The tests for this show output like the following:

The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle records a complete history.

This looks very odd if we have a thin bundle that contains boundary commits instead of a complete history:

The bundle contains these 2 refs:
<COMMIT1> <REF1>
<COMMIT2> <REF2>
The bundle uses this filter: blob:none
The bundle requires these 2 refs:
<COMMIT3>
<COMMIT4>

This separation between tip refs and boundary refs is unfortunate.
Move the filter capability output to the end of the output.
Update the documentation to match.

git bundle now includes in its man page:

Then, 'git bundle' prints a list of missing commits, if any. Finally, information about additional capabilities, such as "object filter", is printed.

The exit code is zero for success, but will be nonzero if the bundle file is invalid.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜