Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull till certain commit (tag)

Tags:

git

git-pull

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
like image 461
Leksat Avatar asked May 07 '13 12:05

Leksat


People also ask

How to pull a specific commit from the git repository?

Below, you can find several ways to pull a specific commit from the Git repository. Using this, you can fetch the changes from the remote repository and then locate the commit’s hash you want to merge to the local codebase. You can refer to the following steps:

How do you name a commit in Git?

For e.g., “v1.0, RC1.0” are some ways to name a commit. Tags can be classified as − A Lightweight tag is also known as a simple tag. These tags use a name to refer to a specific commit. Lightweight tags are private to a repository. These are just pointers to a specific commit.

How does git pull work?

Then "git pull" will fetch and replay the changes from the remote master branch since it diverged from the local master (i.e., E) until its current commit (C) on top of master and record the result in a new commit along with the names of the two parent commits and a log message from the user describing the changes.

What is git commit tag?

The git commit is a 40-digit hexadecimal SHA1 hash. Quite often we need to bookmark a as the commit hash is difficult to memorize. This is where one can use tags. Tags can be used to name a commit.


Video Answer


2 Answers

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.

like image 51
creinig Avatar answered Sep 19 '22 18:09

creinig


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.

like image 28
aymericbeaumet Avatar answered Sep 23 '22 18:09

aymericbeaumet