3

I have a bare_repo that is cloned to three environments. When I work on dev and complete my work I want to be able to tag it and then ssh into test and pull a specific tag up.

Example: Lets say on DEV I make three commits: 1, 2, 3. And lets say I tag it at 2 git tag -a 2. Then I do a git add -u; git commit -m "woo!"; git push --tags. Then I ssh into test and I want to do a git pull but I don't want to pull commit 3. I want to pull only everything up to the tag 2. How do I do this?

EDIT: An alternative to this would be being able to pull specific commits up from the bare repo to the other clones.

Jesse Atkinson
  • 10,586
  • 13
  • 42
  • 45
  • possible duplicate of [GIT pull/fetch from specific tag](http://stackoverflow.com/questions/3964368/git-pull-fetch-from-specific-tag) – Woot4Moo Mar 02 '12 at 14:57
  • I read that already and I don't think it does. – Jesse Atkinson Mar 02 '12 at 14:59
  • I'm interested in the answer as well (how to fetch a specific tag without fetching *all* tags), because fetching *all* tags every time results in a lot of bloat and causes git to `git gc` at the worst possible times (or at least that's what it seems like; it's possible I'm wrong). I wish I could just fetch the tag I'm interested in at the moment. – Quuxplusone Feb 23 '16 at 08:30

1 Answers1

2

Do a

git fetch

to get all changes from the repo followed by a

git reset --hard 2

to get the repository state at this tag.

iltempo
  • 15,718
  • 8
  • 61
  • 72
  • This seems like it's how to get to a specific point in time, but not pulling a single change as the OP seems to be asking. – Michael Durrant Mar 02 '12 at 15:05
  • 1
    Thank you for your answer, but this seems a bit hack-y. Is their really no way to do something like a `git pull --tagname` where TEST and PROD would only pull commits from before and up-to a tag? – Jesse Atkinson Mar 02 '12 at 15:21
  • I would not consider it as being hacky. That's the way some deployment tools are doing it. If you start merging you always risk to get merge conflicts. Especially as a tag can point to very commit regardless if it back of forward in time of even a different branch. – iltempo Mar 02 '12 at 15:56