0

Assume I am working on a branch say B and doing some push to the remote repository in GIT. At some point of time say T1, I created a new tag named T and then again doing some more changes in the branch B. So at time T2 (i.e now) the branch is ahead of the tag by few commits. I want to move those selected new files from the branch (modified files between the time T1 and T2) to the tag T again in remote repository.

I know I can delete the tag T remotely and create a new tag again from the branch B. But I don't want all the files tagged from the branch. Instead I want to move certain files (modified between T1 and T2) from the latest branch to the existing tag.

Is there any way I can do like that ?

Prabu
  • 1,225
  • 4
  • 18
  • 26

1 Answers1

0

"I don't want all the files tagged from the branch"?

In git, tags point to specific commits (look in .git/refs/tags for the list of tags you've got, each one is a file containing the SHA-1 to which the tag pertains).

In your example, you've got a commit (let's call it C1) made at time T1 and, I assume, a commit (C2) made at time T2. You have tagged C1 as "T".

Now you want to push C2 to your remote repository but move the tag on the remote repository to C2 ... but leave your local tag T at C1?

I'd say you should avoid this (it would be confusing to have a tag with the same name but pointing at different commits locally vs. remotely).

Therefore I suggest you move your local tag to C2 (assuming that is the current tip for branch B): git checkout B; git tag -f T then push those changes to your remote repo: git push --tags <remote>.

It would be preferable of course not to move the tag at all, just create a new one. Or don't push to the remote repository until you're sure you've got the repository you way you want it.

Also see How can I move a tag on a git branch to a different commit?

Community
  • 1
  • 1
Gavin
  • 1,223
  • 15
  • 20
  • Sorry I think I failed to explain clearly. I pushed a tag T created at commit C1 to the remote repo. So T is not a local tag. After that C2 happens in the branch. I want to move selected files (between C1 and C2) to the existing tag T (available both locally and remotely). – Prabu Feb 26 '13 at 15:14
  • "T is not a local tag" ... you mean it doesn't exist in your local repository? To get C2 in to the remote repo with tag T you should tag C2 in your local repository with T. Then push that (using git push --tags) to the remote. – Gavin Feb 26 '13 at 15:24
  • Previously I used CVS where I can overwrite existing tag. Now I am clear that it is not possible with GIT as it maintains every commit as snapshot. Thanks for your information. – Prabu Feb 26 '13 at 15:41
  • FYI the -f flag used with `git tag` overwrites the existing tag (it's short for --force). – Gavin Feb 26 '13 at 15:43