I need to delete old and unmaintained branches from our remote repository. I’m trying to find a way with which to list the remote branches by their last modified date, and I can’t.
Is there an easy way to list remote branches this way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
commandlinefu has 2 interesting propositions:
or:
That is for local branches, in a Unix syntax. Using
git branch -r, you can similarly show remote branches:Michael Forrest mentions in the comments that zsh requires escapes for the
sedexpression:kontinuity adds in the comments:
In multiple lines:
Note: n8tr‘s answer, based on
git for-each-ref refs/headsis cleaner. And faster.See also "Name only option for
git branch --list?"More generally, tripleee reminds us in the comments:
(I illustrated that point in 2014 with "What is the difference between
$(command)and`command`in shell programming?")