Reputation: 470
I want to get an archive from a local git repo. The archive should have .git
directory and should not have any files that are not under the track of git. It should look like what I get with a git clone
command. I don't want to use tar
command, because it will include files that are not part of the git repo. I try git archive
, but it does not include .git metadata. What can I do?
Upvotes: 0
Views: 671
Reputation: 271
The official way to do this is with git bundle
. It creates a file with all of the repository information in a single file. Anyone can then use git clone
on it to expand it, just like you would with a remote repository.
cd git-repo
# create the bundle file `repo.bundle`:
git bundle repo.bundle --branches --tags
The produced file can then be cloned.
git clone repo.bundle
There are various ways you can configure what goes into the bundle, including which branches and refs are included. The above example includes all of the tags and branches.
You can also update an existing repository with a bundle file. To do this, add it as a remote, and use the normal pull commands:
git remote add bundle ../repo.bundle
git pull bundle
Upvotes: 0
Reputation: 8010
You can add the extra repo as a remote:
cd
into itgit clone [path to your original repo]
This will make a new folder containing only the files checked in to git, and also a .git
folder.
Upvotes: 1