Vodokan Vodokan - 1 year ago 85
Git Question

git's analog of "hg pull"

In mercurial when I run

hg pull
I will get all of changes from the remote repository but this command won't update the local working dir. When I run
hg update
this command will apply the changes in the working dir.

In git when I run
git pull
the command will get and apply the changes in the working dir.

So my question is how to pull the changes (in git) from the remote repository but not applying them?

Answer Source

I believe the command you are seeking is git fetch. From the documentation:

Fetch branches and/or tags (collectively, "refs") from one or more other repositories, along with the objects necessary to complete their histories. Remote-tracking branches are updated.

Git fetch loads all the changes from the remote without updating your actual local branches. In the blurb above, "remote-tracking" branches are local branches (yes, it's confusing) which track the state in the remote repository, but they are not your local branches.

Assuming you are on branch master, then:

git fetch origin          # updates origin/master
git merge origin/master   # updates your local master

Doing git pull origin master is equivalent to doing git fetch followed by git merge.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download