简体   繁体   中英

How do I update a GitHub forked repository to a specific branch/tag?

I want to upgrade a forked repo which I forked 1 year ago to a specific tag. Anyone know how to do this ?

If you did not already do that:

  • Clone the forked repository on your machine.
  • Add an upstream remote to the original repository ( git remote add upstream <url> )

Then:

  • git fetch upstream --tags
  • git checkout -b <branchname> <tagname>

After that, you will have a new branch named branchname which is at the same state as the tag. Finally,

  • git push origin <branchname>

pushes the new branch to your GitHub fork of the repository.

(I assume this is what you want; if you just want to have the tags in your fork, use git push origin --tags )

我按照以下步骤解决了我的问题:

  • git checkout master
  • git remote add upstream <origianl_repo_link>
  • git fetch upstream
  • git rebase --onto tags/<tag_name> upstream/master master

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