Git remote branches are not available when cloning via http, but are available when cloning locally in a remote machine

I have been stuck for a long time with this. I am sure that this happened due to an error while switching from svn.

On the server where the bare repository is located:

$ git clone /var/git/queryj.git $ cd queryj $ git branch -r origin/HEAD -> origin/remotes/trunk origin/br-0_6--ventura24-2_0-5 origin/master origin/remotes/br-0_6--ventura24-1_0 origin/remotes/br-0_6--ventura24-1_9-stable origin/remotes/br-0_6--ventura24-1_9-synchr origin/remotes/br-0_6--ventura24-2_0 origin/remotes/br-0_6--ventura24-2_0-0 

When cloning a repository via https, I get different results:

 $ git clone https://git.acm-sl.org/queryj.git $ cd queryj $ git branch -r origin/HEAD -> origin/remotes/trunk origin/br-0_6--ventura24-2_0-5 origin/remotes/trunk origin/ventura24-2_0-stable 

Any idea how I can make missing branches available when cloning via https? It is exported via webdav.

+4
source share
2 answers

A git clone by default will not create local branches for all tracking branches.

Remember git for-each-ref when listing Git objects. The --format parameter may actually be the whole script .

For example, to create local branches ( local branches that do not yet exist ), with an upstream branch to this remote (using also the best way to find out if a local Git branch exists? "):

 #!/bin/bash aremote=$1 fmt='r=%(refname); T=$(r#refs/remotes/$aremote/} if [[ "$T" != HEAD ]]; then git show-ref --verify --quiet refs/heads/$T res=$? if [[ "$res" != "0" ]] ; then git branch --set-upstream $T $aremote/$T ; fi fi ' e=`git for-each-ref --shell --format="$fmt" refs/remotes/$aremote` eval "e" 

You would use this script with the name of your remote as a parameter.

+1
source

Cloning over HTTP (without using an intelligent server) uses some additional metadata that is generated from the rest of the repository. This metadata needs to be updated manually, which you can do by running git update-server-info .

0
source

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


All Articles