I am trying to figure out what branch will be fetched if I do git fetch in the current branch, and how can I change that (by some variant of git remote or editing .git/config file).
From what remote branch git pull fetches the contents? Is it the same from which git fetch fetches the contents? Is there a git command which can show me all this information?
To set up the tracked remote branch for a local branch use
So, if you want your local
masterto trackorigin/master, typeHowever,
git fetchfetches all branches of the configured remote.If you have multiple remotes (e.g.
originandother),will fetch the remote
otherwhilewill fetch
origin.To find out which remote branch is being tracked, open
.git/configand search for an entry likeThis tells you that your local branch
mybranchhas<remote_name>as configured remote and that it tracks<remote_branch>on<remote_name>.Which branches are fetched from a remote and how they are called in your local repo is defined in the following section of
.git/config:This tells you that the branches stored under
refs/headsof your origin get fetched and get stored underrefs/remotes/origin/in your local repo.If you are on
mybranchand typegit fetch, the revisions of<remote_name>(specified in the[remote <remote_name>]section) will be fetched. If you typegit pull, after fetching the revisions of<remote_name>the branch<remote_branch>of<remote_name>will be merged intomybranch.Additional information can be found on the man pages of
git branch,git fetchandgit pull.