你是这个意思?
git checkout destination_branch
git merge tag_name
请记住,在合并之前您需要更新标记,它与分支完全不同(git pull origin tag_name
不会更新您的本地标记)。因此,您需要以下命令:
git fetch --tags origin
然后您可以执行 git merge tag_name
将标签合并到一个分支上。
git remote add upstream git@github.com/org/repo
,然后执行 git fetch --tags upstream
才能使其正常工作。
只是补充答案。
合并分支上的最后一个标签:
git checkout my-branch
git merge $(git describe --tags $(git rev-list --tags --max-count=1))
灵感来自 https://gist.github.com/rponte/fdc0724dd984088606b0
这是我发现的唯一全面且可靠的方法。
假设您要将“tag_1.0”合并到“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
我在这里比赛迟到了,但另一种方法可能是:
1) 从标签 ($ git checkout -b [new branch name] [tag name]
) 创建一个分支
2)创建一个拉取请求以与您的新分支合并到目标分支