简体   繁体   中英

Git - Update all new commits from master branch to an existed tag

Can I update all new commits from master branch to an existed tag?

This is how I created the tag:

git tag -a v2.0 -m "Version 2.0"
git push origin v2.0

After that, I pushed some minor changes on master branch.

git add .
git commit -m "Minor changes"
git push origin master

Now the tag has "1 commit to master since this tag". I want to push that commit to v2.0 tag too.

I tried to git checkout v2.0 , then git pull origin master to commit the change to the tag. But after pull from master, the git shows something like 8c62508 instead of v2.0 .

Unlike branches, when you check out a tag you'll end up on a detached head. You simply can't pull into a tag. It is possible to update a tag (I believe you need to delete and recreate it), but it's a really bad idea since Git won't update an existing tag when it changes upstream unless specifically asked to do so. You'd therefore risk having multiple opinions of what a tag points to. You're better off treating tags as immutable. Version numbers are cheap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM