I have cloned a repository and created a local branch named main.
After that I made some changes in the code, committed and wanted to create a .bundle with the commits.
I generate the .bundle using git bundle create test.bundle main
and want to unbundle the commits to check if the file is made correct but when I git clone test.bundle
its just generate a folder with nothing inside.
What am I missing here?
A Git bundle is not a repository. It only contains objects (blobs, trees and commits) but no references (branches, tags, etc.)
When you clone a bundle into a new directory, you get all the commits in that bundle, but no branches or tags to refer to those commits. You need to find the commits and create references for them so they're "reachable".
Here's an example that I reproduced locally:
$ git -C ~/ibugone.com bundle create ~/test.bundle master
Enumerating objects: 6456, done.
Counting objects: 100% (6456/6456), done.
Compressing objects: 100% (3140/3140), done.
Total 6456 (delta 4279), reused 4682 (delta 3063), pack-reused 0
$ git clone ~/test.bundle t
Cloning into 't'...
Receiving objects: 100% (6456/6456), 1.30 MiB | 46.08 MiB/s, done.
Resolving deltas: 100% (4279/4279), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
$ ls -A t
.git
$ git -C ~/ibugone.com log --format=oneline -1
9178ac099b2ea8dc6221acfab8fde074355ef07c (HEAD -> master, origin/master, origin/HEAD) Fix junk items
$ git -C t log --format=oneline -1
fatal: your current branch 'master' does not have any commits yet
128| $ git -C t log --format=oneline -1 9178ac0
9178ac099b2ea8dc6221acfab8fde074355ef07c (origin/master) Fix junk items
$ git -C t reset --hard 9178ac0
HEAD is now at 9178ac0 Fix junk items
$ git -C t log --format=oneline -1
9178ac099b2ea8dc6221acfab8fde074355ef07c (HEAD -> master, origin/master) Fix junk items
$
I create a bundle ~/test.bundle
from my development repo. Then I clone it to ~/t/t
. The new repo contains no branches (because the bundle does not), but I can create a branch from a commit in the new repo (git reset
operates on the default branch on an empty repo). Then there's the master
branch in the new repo.