Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning a repo without tags?

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!! :)

like image 680
love Avatar asked Jul 23 '14 17:07

love


People also ask

Does git clone get tags?

When you clone a repository, all the tags associated with the repository will be pulled down. To fetch all the remote tags, use the fetch command as shown below. You can list down all the tags from the git repository using the following command.

What is git fetch -- no tags?

git fetch fetches all branch heads (or all specified by the remote. fetch config option), all commits necessary for them, and all tags which are reachable from these branches. In most cases, all tags are reachable in this way. git fetch --tags fetches all tags, all commits necessary for them.


1 Answers

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.

like image 119
love Avatar answered Oct 22 '22 00:10

love