Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
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=1
It 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 changes
in 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