I'm trying to find the syntax for merging a tagged commit onto another branch. I guess it's straightforward but my feeble search attempts aren't finding it.
6 Answers
You mean this?
git checkout destination_branch git merge tag_name 7 Comments
Remember before you merge you need to update the tag, it's quite different from branches (git pull origin tag_name won't update your local tags). Thus, you need the following command:
git fetch --tags origin Then you can perform git merge tag_name to merge the tag onto a branch.
1 Comment
git remote add upstream [email protected]/org/repo followed by git fetch --tags upstream to make it work.Just complementing the answer.
Merging the last tag on a branch:
git checkout my-branch git merge $(git describe --tags $(git rev-list --tags --max-count=1)) Inspired by https://gist.github.com/rponte/fdc0724dd984088606b0
Comments
This is the only comprehensive and reliable way I've found to do this.
Assume you want to merge "tag_1.0" into "mybranch".
$git checkout tag_1.0 (will create a headless branch) $git branch -D tagbranch (make sure this branch doesn't already exist locally) $git checkout -b tagbranch $git merge -s ours mybranch $git commit -am "updated mybranch with tag_1.0" $git checkout mybranch $git merge tagbranch Comments
I'm late to the game here, but another approach could be:
1) create a branch from the tag ($ git checkout -b [new branch name] [tag name])
2) create a pull-request to merge with your new branch into the destination branch