How to find which industry is tracking the current branch

I am trying to figure out which branch will be extracted if I do git fetch in the current branch and how to change it (using some git remote option or editing the .git/config file).

From which remote git pull branch is the content retrieved? Is it the same from which git fetch extracts content? Is there a git command that can show me all this information?

+6
source share
1 answer

To configure a monitored remote branch for a local branch, use

 git branch --set-upstream <local_branch> <remote_branch> 

So, if you want your local master track origin/master , type

 git branch --set-upstream master origin/master 

However, git fetch fetches all branches of the configured remote.

If you have multiple remotes (e.g. origin and other ),

 git fetch other 

will display the remote other , and

 git fetch origin 

will display origin .

To find out which remote branch is being monitored, open .git/config and search for an entry like

 [branch "mybranch"] remote = <remote_name> merge = <remote_branch> 

This suggests that your local mybranch branch has <remote_name> as the configured remote and that it tracks <remote_branch> to <remote_name> .

Which branches are retrieved from the remote device and how they are called in your local repo is defined in the following .git/config section:

 [remote "origin"] fetch=+refs/heads/*:refs/remotes/origin/* url=<url_of_origin> 

This means that the branches stored in the refs/heads your source are retrieved and stored in refs/remotes/origin/ in your local repo.

If you are on mybranch and enter git fetch , the changes to <remote_name> (specified in the [remote <remote_name>] section) will be fixed. If you type git pull , after selecting revisions <remote_name> branch <remote_branch> from <remote_name> will be merged into mybranch .

See the git branch , git fetch and git pull pages for more information.

+7
source

Source: https://habr.com/ru/post/894159/


All Articles