Cloning a repo without tags?

love picture love · Jul 23, 2014 · Viewed 11k times · Source

I want to create bare git project without tags using clone.But through Google came to know that there is no option like "--no-tags".

Is there any way to clone without tags like below?

$ git clone {path}/test.git --no-tags --mirror

Any help will be appreciated!! :)

Answer

love picture love · Jul 23, 2014

I also got it through some trails and googling.

I used below steps to make it.

1) Initialize a bare repo:

mkdir project
cd project
git init --bare 

2) Add your remote and configure the proper refspec for it:

git remote add origin <REPO_URL> 
git config remote.origin.fetch +refs/heads/*:refs/heads/* 
git config remote.origin.tagopt --no-tags 

3) Get the data:

git remote update origin 

If you want tags to be omitted just on the very first fetch, then omit setting the remote..tagopt variable and use the

git fetch --no-tags 

for fetching the data instead. Note that the next fetch without "--no-tags" will fetch the auto-fetchable tags unless you set the remote..tagopt configuration option before that.