The title seems a bit weird, so a bit of background:
I got a couples of local git repos, and found myself wanting to make a backup. Two method came to mind,
git bundle and
tar (aware there many other but i wanted something "simple" and that would make repo packed in a "single file")
- Using Tar
The command i tried was
tar cvf gitrepo.tar gitrepo/
Now, this works at first glance, but if i extract it somewhere, a couple of oddities appear, such as:
the git config (the one in .git/config) seems to not be the same one that was put in the tar, but an "older" version. eg: if i edit the config and tar it, then extract it, the config won't have the latest change for whatever reason...
Beside that, everything else seems to work, though i didn't check if other files in the .git folder had similar oddities as the config file.
- Using git bundle
The two command i tried were:
git bundle create repo.bundle
git bundle create repo.bundle --all
The first command work on first glance, but i then noticed it didn't had all the branch, given i didn't use the
The second command work on first glance (again), but, if i git clone said bundle, it end up not containing all the files that are committed in the non-bundled/original local repo...
I thought that the "missing files" were in .git, so i looked for the biggest file there, and found one in .git/objects/pack...so i unpacked it using the following command:
cd "$@"/.git/objects/pack ; mkdir ~/SAMPLE; mv *.pack ~/SAMPLE; git unpack-objects < ~/SAMPLE/*.pack; rm -rf ~/SAMPLE
$@ being the name of the local repo that was cloned from the git bundle.
I didn't solve the above issue but i did notice that some of the commit history was restored, albeit with files still missing from the original repo.
So I'm confused at to how correctly backing up my local git repo (preferably in a single file) while still retaining latest change on file and without missing files? (as in, all commit history, branch, etc)