2017-11-03 6 views
0

対Gitのブランチ-a postコマンドは、リモートブランチに関連して、同じ出力を生成する必要があります後は、しかしリストリモートブランチ - GitのLS-リモート--heads原点

git fetch 
git branch -a 

見えしばらくされていないリモートの支店を示し実行中

git ls-remote --heads origin 

この動作の理由は何ですか?

[明確化]あなたのマシン上で、ローカルに存在し、どちらもgit branch -aリストすべてのローカルおよび追跡の枝を、実行

(TA216441) $ git pull 
Your configuration specifies to merge with the ref 'refs/heads/TA216441' 
from the remote, but no such ref was fetched. 

(TA216441) $ git fetch 
(TA216441) $ git branch -a 
* TA216441 
    TA216442 
    master 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/TA212425 
    remotes/origin/TA216441 
    remotes/origin/TA219346 
    remotes/origin/TA220305 
    remotes/origin/TA223738 
    remotes/origin/master 

(TA216441) $ git ls-remote --heads origin 
    hash-1 refs/heads/DE18756_2 
    hash-2 refs/heads/TA212425 
    hash-2 refs/heads/TA219346 
    hash-3 refs/heads/TA220305 
    hash-4 refs/heads/master 

答えて

0

master 
branch1 
remotes/origin/HEAD -> origin/master 
remotes/origin/master 
remotes/origin/branch1 

あなたがgit ls-remote --heads originを実行したときしかし、それはあなたのレポでリモート頭の参照を示しています。ここで私はgit branch -aを実行したときに、私が得たものです。同じレポのために、これは私が見たものである:

b9e515799... refs/heads/master 
9a7faebd1... refs/heads/branch1 

レポはあなたが実際にあなたがgit pullのようなものを使用した場合とパクているものである、真のリモートブランチがあります。

+0

枝が削除されたようですが、git branch -aは実際に枝がリモートに存在するかどうかをチェックしません。 –

+0

@BartekWichowski:正しい: 'git branch -a'はローカルで動作し、別のGitには決して接触しません。 'git ls-remote'は他のGitを呼び出し、それに質問します。もしあなたが好きであれば、 'git fetch --prune origin'を実行して、Gitが' origin'でGitを呼び出し、新しいコミットをダウンロードし、あなたのローカルコピーを更新し、これを "prune"あなたが持っていないブランチに対して持っている遠隔追跡ブランチを部分的に*削除*します。つまり、あなたの 'origin/*'遠隔追跡ブランチを「剪定」します。 – torek

+0

@BartekWichowski(続き)デフォルトで* *を実行したい場合は、その設定があります。 [prune]という単語について[git config'のドキュメント(https://www.kernel.org/pub/software/scm/git/docs/git-config.html)を検索してください。 – torek

関連する問題