Yo-L
Yo-L

Reputation: 487

Git tagging for old state with uncommitted changes

I got myself a situation and I am pretty new with git.

I have redeveloped a theme for Wordpress 3 from beeing used in Wordpress 2 without the knowledge that the theme was actively used at another location.

Now I need to tag this old version as V1 and the current as V2 as I think this would be the best approach.

My problem is that this old state also have some uncommitted changes.

Commiting them and pushing before tagging would not be optimal.

My solution:

Is this the correct way to approach this problem?

Is it something i need to think about before i do this?

Thanks in advance. /Joel

Upvotes: 0

Views: 1440

Answers (1)

sehe
sehe

Reputation: 393507

My problem is that this old state also have some uncommitted changes. Commiting them and pushing before tagging would not be optimal.

I may be getting you wrong, but what would be the use of tagging uncommitted stuff at all?

My solution: - branch the old state - commit the files to the new branch - tag the old master - merge my branch with the old master.

That sounds like a horrendous detour of just committing the changes directly on master and tagging that commit. Try it: there is no difference. /confused/


Do you perhaps mean that you have a patch that you want applied to an old version, than tag the result of that as V1? In that case what you describe is one way of doing it nicely.

Another is:

git stash save amendments_for_v1
git checkout -b v1_branch oldrevision
git stash pop amendments_for_v1
git commit -am 'amendments'
git tag V1

git checkout master

now depending on whether you have published history since the oldrevision revision, you could do

git merge v1_branch      # includes amendments, but doesn't create problems with published history

or

git rebase v1_branch     
# includes the same amendments, _as if they had been there before 
# doing the rest of the work on master_. This results in 'clean' or 
# 'logical' history *BUT* invalidates the published revisions since oldrevision from the master branch

Upvotes: 1

Related Questions