Yvon
Yvon

Reputation: 2993

git: How to prevent fetching tags from upstream repo?

I'm new to forking a repo in GitHub. The situation is I have forked my own project, and trying to port the new one into another platform. My original project has many tags corresponding to different versions. But I want to use a different pace (and different version numbers) to update the new project, so I don't want to use any of them in my new project.

The question is that is there any way to prevent commands like git fetch from getting all unnecessary tags from upstream repo?

Even if I remove all not-needed tags from my new repo, after next git fetch they will come back.

Upvotes: 13

Views: 2188

Answers (2)

Jens Bannmann
Jens Bannmann

Reputation: 5115

Yes, you can configure this separately for each remote.

For example, if the origin remote points to your new project (with the tags you want) and upstream points to the original project (with the tags you don't want), enter the following:

git config remote.upstream.tagOpt --no-tags

Then, delete the local tags one last time, and git fetch will no longer recreate them.

Source: https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---no-tags

Upvotes: 15

Ry-
Ry-

Reputation: 225074

git fetch accepts a --no-tags (-n) option. I wouldn’t use it, though; if you change the versioning scheme of software, you shouldn’t clobber its existing versions. That’s just confusing.

Upvotes: 4

Related Questions