How do I merge a git tag onto a branch

Git MergeGit Tag

Git Merge Problem Overview


I'm trying to find the syntax for merging a tagged commit onto another branch. I'm guessing that it's straight forward but my feeble search attempts aren't finding it.

Git Merge Solutions


Solution 1 - Git Merge

You mean this?

git checkout destination_branch
git merge tag_name

Solution 2 - Git Merge

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.

Solution 3 - Git Merge

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

Solution 4 - Git Merge

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

Solution 5 - Git Merge

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJeremy WoodlandView Question on Stackoverflow
Solution 1 - Git MergetwalbergView Answer on Stackoverflow
Solution 2 - Git MergeDeadManSpiritView Answer on Stackoverflow
Solution 3 - Git Mergee-ruizView Answer on Stackoverflow
Solution 4 - Git MergepaiegoView Answer on Stackoverflow
Solution 5 - Git MergeForTheWinView Answer on Stackoverflow