github中fork别人的项目,clone下来后发现只有代码,没有tag,而我们现在想基于某个tag生成新分支,然后基于这个分支来开发。
第一步,需要把原来的tag都同步过来
# Fork源仓库
# Repo: aaa/project
# Fork: bbb/project
# Track:
# 克隆你的仓库
git clone https://github.com/bbb/project.git
# 进入你的仓库本地目录
cd project
# 添加原始仓库地址
git remote add upstream https://github.com/aaa/project.git
# Update:
# 拉取原始仓库数据
git fetch upstream --tags
# 如果你的主分支不是叫master,就把前面的master换成你的名字,比如main之类
git rebase upstream/master
# 推送
git push
# 推送tags
git push --tags
第二步,基于某个tag新建分支,并推送到远程仓库
# 查看所有tag
git tag
# 4. 检出指定的 tag 到新分支
# 替换 'tag_name' 为你想要的 tag 名称
git checkout -b new_branch_name tag_name
# 将新分支推送到远程仓库
git push -u origin new_branch_name
参考文献
https://www.cnblogs.com/bodong/p/17891893.html