0

i do git ls-remote and i get the remote branches and the commit IDs. is there away to get the branch names without the commit IDs.? this is what i do :

git ls-remote --heads

and im getting this result:

038700e8xxxxxxc96bb78adc6d22287370        refs/heads/release/ddddd.3
d9ebd03axxxxx212fdf63f22b092aaff6c6f0e    refs/heads/release/ddddd.4
63a9be2d6a77414c65189ea0ef76d65a23a3e910  refs/heads/release/ddddd.4
db6cf449xxxxxx15cbf711745f94875ed18bd     refs/heads/release/ddddd.5
49ba61331ebaca7aexxxxxxf2e9dfc9b5591      refs/heads/release/ddddd.6
acc32db7f25d2b3e616613a389c93eae82d46323  refs/heads/release/ddddd.7

not using linux tools , as im using windows also can't rely on awk and friends

user63898
  • 29,839
  • 85
  • 272
  • 514
  • Can you explain what you try to achieve please? You mention "checkout a single file" in the comments, but listing branches is unrelated with file checkout. – padawin May 21 '19 at 18:48

3 Answers3

2

Could do

git ls-remote --heads | cut -f 2
battlmonstr
  • 5,841
  • 1
  • 23
  • 33
  • 'not using linux tools, as im using windows also can't rely on awk and friends' Your answer contains cut. – tim687 Dec 15 '19 at 14:53
  • If you don't need to be cross-platform, you can try a PowerShell equivalent of "cut": https://stackoverflow.com/questions/24634022/what-is-an-equivalent-of-nix-cut-command-in-powershell – battlmonstr Dec 16 '19 at 09:47
0
git ls-remote --heads origin | awk '{print $2}'
phd
  • 82,685
  • 13
  • 120
  • 165
  • 'not using linux tools, as im using windows also can't rely on awk and friends' Your answer contains awk. – tim687 Dec 15 '19 at 14:53
-1

You can get the remote branches with:

git branch --remote

Is it what you are after?

padawin
  • 4,230
  • 15
  • 19
  • im using this method to checkout single file so ( i don't know why really ) it doesn't work like in this link https://stackoverflow.com/questions/4114887/is-it-possible-to-do-a-sparse-checkout-without-checking-out-the-whole-repository – user63898 May 21 '19 at 18:04
  • It will not list remote branches that are not fetched to your local repo. `git ls-remote` will connect to the remote and list all of the missing branches. – Marcin Kłopotek Jun 22 '22 at 14:13