Having a hard time understanding git-fetch

First, there’s no such concept of “local tracking” branches, only “remote tracking” branches. So origin/master is a remote tracking branch for master in the origin repo.

Typically you do git fetch $remote which updates all your remote tracking branches, and creates new ones if needed.

However, you can also specify a refspec, but that will not touch your remote tracking branches, instead, it will fetch the branch you specified and save it on FETCH_HEAD, unless you specify a destination. In general you don’t want to mess with this.

Finally:

fetch = +refs/heads/*:refs/remotes/origin/*

That means if you do

git fetch origin

It will actually do:

git fetch origin +refs/heads/*:refs/remotes/origin/*

Which means a remote heads/foobar will be the local remotes/origin/foobar, and the plus sign means they’ll be updated even if it’s non-fast-forward.

So your local origin/foobar will always be the same as foobar on the origin remote (after running git fetch). And origin/master will obviously be the same as master on the origin remote. So will all the other remote tracking branches.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)