Tuesday, 15 March 2011

bash - Changing / adding files to a git tag? -



bash - Changing / adding files to a git tag? -

i'm familiarizing myself git , now, git tags. based on i've understood date, tags snapshot of point in time in history want track. example, version numbers.

i have client wants me add together / backport bug prepare version 1.0 when on version 2.0. thought beingness when image new v1.0 box, bug prepare included.

i'm not sure how this.

i have next tags in repo:

v2.0 v1.0 v0.1

i've tried check out tagged version running command

git checkout v1.0

then made bug prepare changes. , tried:

git add together . git commit git force

when push, error message stating updates rejected because pushed branch tip behind remote counterpart. i'm googling error know if fundamentally, i'm doing shouldn't.

overriding tag/version bad practice in general. since want prepare bug older version, way git works create new tag bug fixed.

that's why have changelog thing -- helps humans view differences between versions/releases.

in case of fixing bug in older version (v0.1.0) while new version (v0.2.0) has log of changes , cannot synced old one, want create new tag v0.1.1:

# creating v0.1.0 git init echo "console.log('hello wrold')" > main.js git add together . git commit -m 'initial commit' git tag v0.1.0 git remote add together origin ... git force --all git force --tags # creating v0.2.0 echo "console.log('hello mars')" > main.js git commit -m 'hello mars instead of hello world' . git tag v0.2.0 git force --all git force --tags # fixing typo v0.1.0 (edit/add files) , creating v0.1.1 git checkout v0.1.0 echo "console.log('hello world')" > main.js git commit -m 'fixed typo.' . git tag v0.1.1 git force --tags # go main branch git checkout master

fixed typo. commit not appear in master branch since added in v0.1.1 tag.

so, if want override v0.1.0? if that's bad practice, doesn't create impossible. instead of creating new version (git tag v0.1.1) can delete old v0.1.0 , create again, forcing pushing on remote:

... # fixed typo git tag -d v0.1.0 git tag v0.1.0 git force --tags -f # go main branch git checkout master

on github, releases listed this:

let's see differences:

$ git diff v0.1.0 v0.2.0 diff --git a/main.js b/main.js index 07e8cb2..7b366c5 100644 --- a/main.js +++ b/main.js @@ -1 +1 @@ -console.log('hello wrold') +console.log('hello mars') $ git diff v0.1.1 v0.2.0 diff --git a/main.js b/main.js index ba72797..7b366c5 100644 --- a/main.js +++ b/main.js @@ -1 +1 @@ -console.log('hello world') +console.log('hello mars') $ git diff v0.1.0 v0.1.1 diff --git a/main.js b/main.js index 07e8cb2..ba72797 100644 --- a/main.js +++ b/main.js @@ -1 +1 @@ -console.log('hello wrold') +console.log('hello world')

git bash tags

No comments:

Post a Comment