0

I'm building a continous integration pipeline based on a git repository.

I have 3 branch:

  • master branch for the dev environment
  • test branch for the test environment
  • prod branch for the prod environment

Any time a branch is updated, a pipeline update my website, eg:

Everytime I release a new version, I update the master branch and tag the commit whit the version number:

# procedure for deploy on dev git add -A git commit -m "1.0.0" git tag 1.0.0 git push --set-upstream origin master --tags 

This works...

When i want to put the 1.0.0 version into test environment this is the procedure

# procedure for deploy on test git fetch --tags origin git checkout -B test git merge 1.0.0 git push --set-upstream origin test 

This works... but this procedure don't work on rollback, if test branch is on version 2.0.0 the snippet don't rollback the branch on version 1.0.0. If i made a:

git show-branch *test 

the output show:

! [refs/remotes/origin/test] 2.0.0 * [test] 2.0.0 -- +* [refs/remotes/origin/test] 2.0.0 
5
  • What do you mean by rollback? Commented Apr 10, 2020 at 10:18
  • i mean... if i try to merge a previous tag, with the shared snippet, the branch still on the last version... Commented Apr 10, 2020 at 10:23
  • That's exactly what you should expect. A tag is a pointer to a specific commit, and does not move. Merge means make a new commit (except when Git can do a fast-forward instead, and you allow or require a fast-forward), and you would normally do this while being on a branch name; that moves the branch name forward. So now the branch name identifies a merge commit, and the branch contains the merge commit and both tagged commits. Commented Apr 10, 2020 at 10:43
  • I would not call a merge a rollback though. A merge is a merge, so call it a merge. Commented Apr 10, 2020 at 10:46
  • ok thanks... now i have understand Commented Apr 10, 2020 at 10:48

1 Answer 1

3

you can try to reset the branch and after push it

git reset --hard <tagname> git push -f -u origin branch 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.