10

I have a clone of a remote repository. I updated its remote url to my own server. Then I did some commits and pushed them to my repository. Now I need to pull some changes from the initial repository. From a specific branch. I can do it by running

git pull http://example.com/repo.git example_branch

This will pull every new commit from example_branch (and actually I will get a dev version). But this example_branch has tags. And I need to stop pulling at a certain one (get a stable release in my case). How can I do that?

UPD Finally I came up with:

git remote add example http://example.com/repo.git
git fetch
git merge tag_name
Leksat
  • 2,923
  • 1
  • 27
  • 26
  • I think you're trying to solve the wrong problem. Why would you want to pull only up to a specific commit? – Arjan May 07 '13 at 12:40
  • 1
    Well, if I pull all commits from a branch, I will get a dev version. But I need a stable release. – Leksat May 07 '13 at 12:42
  • see also: https://stackoverflow.com/questions/31462683/git-pull-till-a-particular-commit/64558798 – dbn Dec 14 '20 at 22:15

2 Answers2

11

git pullis just a git fetch followed by a git merge. So you can easily do a git fetch and then merge the desired commit / tag.

creinig
  • 1,560
  • 12
  • 23
  • 20
    Why not write the commands for doing this instead of just saying you can easily do this? – Joe C Jun 26 '14 at 22:00
2

A git repository can supports multiple remote.

In your case, you need to add a second remote (with your old server):

git remote add old_server http://example.com/repo.git

Then you can simply fetch from it:

git fetch old_server

At last, merge the specific commit you want to grab into your project.

Community
  • 1
  • 1
aymericbeaumet
  • 6,853
  • 2
  • 37
  • 50