Skip to content

Instantly share code, notes, and snippets.

@yuya-maemichi-synspective
Last active May 21, 2024 03:46
Show Gist options
  • Save yuya-maemichi-synspective/406de7190d4b3167899d4f65fa071ebc to your computer and use it in GitHub Desktop.
Save yuya-maemichi-synspective/406de7190d4b3167899d4f65fa071ebc to your computer and use it in GitHub Desktop.
Git snippets
git remote |
xargs -n1 -I% git symbolic-ref refs/remotes/%/HEAD |
cut -d/ -f4
# cf. %x`echo exec cmd`
def x(cmd)
IO.popen(cmd).readlines(chomp: true)
end
x('git remote')
.flat_map{x("git symbolic-ref refs/remotes/#{_1}/HEAD")}
.map{File.basename(_1)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment