dswisher / git-exec-wrapper

A dotnet class library that provides a (hopefully) easy-to-use wrapper around command-line git
MIT License
0 stars 0 forks source link

Implement a way to get remote information #5

Open dswisher opened 2 years ago

dswisher commented 2 years ago

One specific use case: determine the default branch for a remote.

This SO post suggests the use of git remote show <remote>, which produces output like the following:

* remote origin
  Fetch URL: git@github.com:dswisher/git-exec-wrapper.git
  Push  URL: git@github.com:dswisher/git-exec-wrapper.git
  HEAD branch: develop
  Remote branches:
    develop                  tracked
    main                     tracked
    refs/remotes/origin/nuke stale (use 'git remote prune' to remove)
  Local branches configured for 'git pull':
    develop merges with remote develop
    main    merges with remote main
  Local refs configured for 'git push':
    develop pushes to develop (up to date)
    main    pushes to main    (up to date)

Note the HEAD branch line, which is the default branch for the remote.