Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git fetch doesn't update my local repository

Tags:

git

git-fetch

What I want:

Update all news commits from server with my local repository in all branch but do not merge any branch (just join the history lines).

I am trying this command

git fetch --force --progress --verbose  name@host:/path/to/repository.git  

I thought it will work fine, because it show:

From host:/path/to/repository   * branch            HEAD       -> FETCH_HEAD 

But, what means this output? If I see the log, it wasn't update. If I do a clone from server, all new commits are there. So... The command not work. Then I try with a branch that exist in server but not in my local repository

git fetch --force --progress --verbose  name@host:/path/to/repository.git my_branch 

The result is:

From host:/path/to/repository   * branch            my_branch       -> FETCH_HEAD 

And any success... Even if I not know all branches and my branch was update, I want to fetch this changes and can see in my log.

Any idea to do it work?

like image 391
Rodrigo Avatar asked Mar 23 '12 14:03

Rodrigo


People also ask

Why git pull is not updating my local branch?

To remedy this, run the git stash command to stash your local changes before running the git pull command. The last step is to run the git stash apply after the git pull command. This command will apply the stashed changes to your working directory. You can also commit the changes before running the git pull command.

Does git fetch update local branch?

git fetch downloads commits from the remote branch, but doesn't update your workspace. You won't see the commits until they are merged into your local branch.

When I run git fetch from my local repo it will update my local code?

Answer. When you fetch you get the remote branches, but you still need to merge the changes from the remote branch into your local branch to see those changes.

Does git fetch update files?

git fetch is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn't do any file transferring. It's more like just checking to see if there are any changes available). git pull on the other hand does that AND brings (copy) those changes from the remote repository.


1 Answers

When you fetch you get the remote branches, but you still need to merge the changes from the remote branch into your local branch to see those changes.

After fetching, try this:

git log origin/yourbranchname | head git log yourbranchname | head 

Do you see the difference?

Now do:

git checkout origin/yourbranchname -b newbranchname git log newbranchname 

You should see remote changes in the newbranchname.

You can also merge those changes into your branch with

git checkout yourbranchname git merge origin/yourbranchname 
like image 111
George Skoptsov Avatar answered Sep 28 '22 11:09

George Skoptsov