clone
is used in git to copy a project into your machine as a git project and do you works on it. Sometime a project (specially front projects) are so heavy and has lots of history which makes cloning to takes an hour or more (depending on the depth and the size of the repo).The solution is
--depth
, with --depth
you can specify how shallow a clone could be and how much commit of the past should be brought into your system. So for example you can clone like this:git clone myhost:frontier/web.git --depth=1It will copy the whole project
BUT
it just copies the last commit on the tip of the current branch in your server (most likely master) which is the default behaviour of git that set --single-branch
. So if you checkout to dev you wont see your last changesin
dev
branch. In case you want to shallow copy the whole project and retrieve the lat commit on the tip of all remote branches just use --no-single-branch
.So finally we can:
git clone myhost:frontier/web.git --depth=1 --no-single-branch
Now if you change your branch (checkout) to
dev
, you will see that recent changes of the dev
branch on the remote repo server is present in your system.to see the last commit ids that you have in your system, open
YOUR_PROJECT/.git/shallow
file and see the content of the file. Mine is as below:8252b87c82b4be7b7b4edaa12f2168ff165fc7af #refers to my master last commit id
d50bdeeecc595e86818c68d734613542206bf972 #refers to my dev last commit id
#git #branch #no-single-branch #single-branch #depth #clone
How to delete a git branch?
https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote
#git #branch #delete
https://makandracards.com/makandra/621-git-delete-a-branch-local-or-remote
#git #branch #delete