Detailed explanation of 'git remote show'

I honestly can't find the detailed documentation on git remote show exit (of course, not on the man page )

In particular, a clear and precise explanation of the Local sections would be understandable.

An example of what I'm confusing:

Here I have two remote controls, klas and origin, and the output they produce:

 > git remote show klas * remote klas Fetch URL: ..\klasrepo Push URL: ..\klasrepo HEAD branch: master Remote branches: experiment tracked feature tracked master tracked pu tracked stashbranch tracked Local branch configured for 'git pull': pu merges with remote pu Local refs configured for 'git push': experiment pushes to experiment (fast-forwardable) feature pushes to feature (fast-forwardable) master pushes to master (fast-forwardable) pu pushes to pu (up to date) > git remote show origin * remote origin Fetch URL: C:/Temp/git/.\barerepo.git Push URL: C:/Temp/git/.\barerepo.git HEAD branch: experiment Remote branches: experiment tracked master tracked Local branches configured for 'git pull': experiment merges with remote experiment master rebases onto remote master Local refs configured for 'git push': experiment pushes to experiment (up to date) master pushes to master (fast-forwardable) 

Note that the experiment and the wizard are listed as local refs configured for 'git push' . What does it mean? I configured the master and experiment to track origin / master and origin / experiment respectively (and pu to track klas / pu).

My local function branch is not configured to track anything, but is still listed in the local refs configured for 'git push' section (the only connection is similar to the identical name, the other that does not track the branch, foo, is not mentioned). git push While the on function gives fatal: The current branch feature has no upstream branch. - hardly "fast forward".

It seems that the criteria for the local branch listed in local refs configured for 'git push' is that there is a remote branch with the same name

For reference:

 > git branch -vva experiment 0cf7b2a [origin/experiment] added rand content 82 to .\rand_content.txt * feature 4b25f46 added rand content 62 to bar.txt foo 40aee50 added rand content 17 to .\rand_content.txt master 4b25f46 [origin/master] added rand content 62 to bar.txt pu 44ad10b [klas/pu] added rand content 51 to doo.txt remotes/klas/experiment 1f4e89b app remotes/klas/feature 884e953 added rand content 80 to bar.txt remotes/klas/master 57877c1 added in tobias repo remotes/klas/pu 44ad10b added rand content 51 to doo.txt remotes/klas/stashbranch 8678cf0 added rand content 44 to .\rand_content.txt remotes/origin/HEAD -> origin/master remotes/origin/experiment 0cf7b2a added rand content 82 to .\rand_content.txt remotes/origin/master 4b25f46 added rand content 62 to bar.txt > git config --list --local | select-string 'branch|remote' remote.origin.url=C:/Temp/git/.\barerepo.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master branch.master.rebase=true remote.klas.url=..\klasrepo remote.klas.fetch=+refs/heads/*:refs/remotes/klas/* branch.experiment.remote=origin branch.experiment.merge=refs/heads/experiment branch.pu.remote=klas branch.pu.merge=refs/heads/pu > git --version git version 1.8.1.msysgit.1 
+6
source share
1 answer

It looks like a bug in Git 1.8.1.

Taking the Git source code (in particular, remote.c and builtin/remote.c ), the list in the section "Local links configured for" git push "is calculated as follows:

  • collect configured push refspecs:
    • read .git/remotes/<remotename> (legacy configuration file, see git help repository-layout )
    • read .git/branches/<branchname> (another legacy configuration file)
    • view the remote.<remotename>.push
  • If step # 1 did not find anything, use : as the only push refspec
  • find all {local, remote} branch combinations that match the compiled push refspecs

Note that the above algorithm does not pay attention to branch.<branchname>.remote , branch.<branchname>.merge or push.default .

With typical usage patterns, step # 1 in the above algorithm will never find the configured refspec, therefore : will be used. This refspec is a simple matching refspec, so with typical use of git remote show <remotename> will always print <branchname> pushes to <branchname> if there is a branch named <branchname> in the local and remote repositories.

+4
source

All Articles