2

I want to sync remote tree to my local machine using particular tag.What is the best ways to sync tree using tag other that git checkout.Because if i use git checkout I need to sync latest top of tree for every repo and then checkout to that particular tag.

mrutyunjay
  • 6,850
  • 7
  • 25
  • 35

2 Answers2

2

You can first do a:

git fetch ; git fetch --tags

(2 fetches, just to be sure to get all commits: see "Does “'git fetch --tags'” include “'git fetch`'?")

It won't update your local working tree (contrary to a git pull).

From there, you can do a:

git checkout aTag    

(which works, but leave you in a DETACHED HEAD mode)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • but this will be same as 1. repo sync and then 2. git checkout – mrutyunjay Apr 19 '13 at 08:45
  • @Themj you *need* to fetch those tags, otherwise, you won't see them in your local repo. – VonC Apr 19 '13 at 08:48
  • @Themj again, your local files aren't changed by a git fetch. You need at least (to get the minimum amount of commits) a `git fetch --tags` – VonC Apr 19 '13 at 08:56
  • last one what if someone adds new repos?? I am using tag of day 1 and if someone adds one repo on day2.. this new repo will not contains this tag it will give you error... How to avoid this?? – mrutyunjay Apr 20 '13 at 15:40
  • @Themj you would need to add the url of that new repo as a remote (git remote add) and git fetch --tags newremote. – VonC Apr 20 '13 at 15:43
  • sorry it is not clear to me :( I am using tag1 to sync tree but suppose I dont have this tag1 in repo abc which is newly added.. Now repo sync will give you error that revision not found or something like this.. now what should i do?? – mrutyunjay Apr 21 '13 at 18:23
  • @Themj Since repo `abc` doesn't contain `tag1`, you need to add as a remote ([`git remote add`](http://git-scm.com/docs/git-remote)) the url of a repo who *does* contain tag1, which will allow you to sync your local repo with tag1 coming from that remote repo. The key here, is that you can add as many remote as you need to a local repo, and sync that local repo (with a `git fetch --tags` first) against any of those remote repo. Just pick one which does contain tag `abc`. – VonC Apr 21 '13 at 19:29
2

You can use

   repo init -u <path to manifest repo> -m <manifest name> -b refs/tags/<tag_name>