Initialization might not be the way to go depending on your use case. It will be especially tedious if there is a very big repository(mine was 16GB and Ineeded to do this), and in fact will blow away local refs+objects
which is no good if your archive represents an archive for which a remote no longer exists.
You need the repository to be copied in two steps:
- "Data Files" (HEAD Revision possibly unstaged)
- Indices and Objects ie. history+refs+objects :This records your baseline, deltas, branch pointers and tags.
The objective is to reduce how many object must be cloned from a remote or which cannot be recreated from a remote which no longer exists. Additionally you want your config to not conflict with the local config files of whoever initially created the repository
You want to preserve the repository layout for objects and refs which not longer exist in the remote or which you don't want to copy (e.g they're large image assets). For this reason you don't want to init and pull, especially if you don't have a remote anymore.
Instead the repository is already in an acceptable state with refs and objects intact. The only problems may be if the remotes are no longer setup properly and your config may be set improperly.
Run git config --local -l
to verify that the commit identity is not set locally in the repository and change any keys which override your global settings in a way you don't want.
Now that it's configured treat the repository now as if it were your own(because it is), git is designed to work distributed so once you alter any local config, it is effectively no different, than as if it were cloned. The only thing remaining is you have to insure your remotes are setup properly.
If you do not have remote but wish to create one, create it on the remote server using git init --bare
then add a remote as usual and push all refs git push --all
. Making a repository bare means it will accept the first push without complaining about a diverged history.
If you have an existing remote repository, add it as a remote and pull. The archive branches may be pointing to the wrong url depending how long ago the archive was made, if this is the case, use git remote
to assign them to new locations or remove any dead urls.
Once remotes have been setup fetch and pull to get up to date. If there is a detached HEAD, checkout the desired branch. If the history of the archived repository has diverged from the remote, git will produce a merge conflict, resolve as normal, stashing changes if necessary.
clone --bare ...
still downloads the large contents. – Corliss