Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: How do I pull a tagged revision into my fork?

Tags:

git

github

I have a fork of a project on github where the main trunk was recently tagged. I want to pull the code from the tagged revision into my fork. How would I do that?

like image 788
Jon Kruger Avatar asked Aug 31 '09 11:08

Jon Kruger


People also ask

How do I pull updates into a fork?

To sync your forked repo with the parent or central repo on GitHub you: Create a pull request on GitHub.com to update your fork of the repository from the original repository, and. Run the git pull command in the terminal to update your local clone.

How do I pull a tag in git?

Checkout Git Tag To fetch tags from your remote repository, use “git fetch” with the “–all” and the “–tags” options. Let's say for example that you have a tag named “v1. 0” that you want to check out in a branch named “release”. Using this command, you have successfully checked out the “v1.


2 Answers

Once you have the tag in local repository you can do something like

git merge tags/yourtag

If you don't have the "trunk" tags locally, you can fetch it using

git fetch remote-url "refs/tags/*:refs/tags/*"

Or by setting up the remote

git remote add upstream remote-url

and fetching the stuff using

git fetch -t upstream

I think, though, using

git remote update

will have similar effect.

like image 179
Michael Krelin - hacker Avatar answered Sep 22 '22 02:09

Michael Krelin - hacker


I may be projecting, but I think Jon's problem was the same as mine:

I forked someone else's project (on GitHub), and needed to point the master branch of my fork to a specific tag of their project, effectively ignoring all subsequent development. (Why? After that tag, their project dropped functionality that my fork depends on and must build on. So I'm pegged to that moment in history. Sad but true.)

In this example, the tag was called 0.6.3. All I had to do was cd to my local clone (of my fork) and do

git reset --hard 0.6.3 git push --force 

Then I verified on GitHub that my fork reflected the state of the code at their tag!

like image 29
Adam Florin Avatar answered Sep 20 '22 02:09

Adam Florin