How to convert a Git shallow clone to a full clone?
GitCloneGit Problem Overview
Follow-up of this so-question: if I have a shallow clone, how to fetch all older commits to make it a full clone?
Git Solutions
Solution 1 - Git
The below command (git version 1.8.3) will convert the shallow clone to regular one
git fetch --unshallow
Then, to get access to all the branches on origin (thanks @Peter in the comments)
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
Solution 2 - Git
EDIT: git fetch --unshallow
now is an option (thanks Jack O'Connor).
You can run git fetch --depth=2147483647
From the docs on shallow:
> The special depth 2147483647 (or 0x7fffffff, the largest positive number a signed 32-bit integer can contain) means infinite depth.
Solution 3 - Git
I needed to deepen a repo only down to a particular commit.
After reading man git-fetch
, I found out that one cannot specify a commit, but can specify a date:
git fetch --shallow-since=15/11/2012
For those who need incremental deepening, another man
quote:
> --deepen=
Solution 4 - Git
Two ways to achieve Shallow Clone to Deep Clone. :
-
Used the following steps to download the branch: (This downloads the shallow copy of the branch and then converts it into a Full Clone i.e bring complete branch and its history).
a. git clone -b branch http://git.repository/customSP01.git --depth 1
This does a shallow clone (with the depth-option) only fetches only one single branch (at your requested depth).
b. cd customSP01
c. git fetch -depth=100
d. get fetch -depth=500
....
e. git fetch --unshallow
//The above command will convert the shallow clone to regular one. However, this doesn’t bring all the branches:
Then, to get access to all the branches.
f. git remote set-branches origin '*'
[This Step can also be done manually by editing following line in .git/config.
fetch = +refs/heads/master:refs/remotes/origin/master
to (replace master with *):
fetch = +refs/heads/*:refs/remotes/origin/* ]
g. git fetch -v
This converts the Shallow Clone into Deep Clone with all the History and Branch details.
-
You can avoid steps f and g, if you use the below instead of command present in step a. to do the shallow clone:
git clone -b branch --no-single-branch http://git.repository/customSP01.git --depth 1
Solution 5 - Git
You can try this:
git fetch --update-shallow
Solution 6 - Git
None of the above messages did the trick. I'm trying to work with git tags starting from a shallow clone.
First I tried
git fetch --update-shallow
which kind of worked half-way through. Yet, no tags available!
git fetch --depth=1000000
This last command really fetched the tags and I could finally execute
git checkout -b master-v1.1.0 tags/v1.1.0
and be done with it.
HTH