webuser57
webuser57

Reputation: 171

git show only remote branches

how can I show branches by date on server?
On this page I have following query found:

for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort –r

With git branch -rv I can see the branches on the server, but no additional information.

How could you build such a thing, but only for the server, ie. Show all branches, which are located only on the server?

Unfortunately, I am familiar with the console not good enough to make it rebuild itself :-(

Upvotes: 1

Views: 186

Answers (2)

jstuartmilne
jstuartmilne

Reputation: 4508

I think that what you are looking for is git-for-each-ref

For your particular requirement it would be something like this:

git for-each-ref --sort=-authordate --format='%(authordate:short) %(refname)' refs/heads refs/remotes

This will print your remote branches orderderd by author date

Hope it helps

Upvotes: 1

bcmcfc
bcmcfc

Reputation: 26795

git branch has a --sort option.

So you can do:

git branch -r --sort=authordate

To show only remote branches sorted by the author date. Use committerdate for the commit date.

To reverse the order, add - to the sort field:

git branch -r --sort=-authordate


See this link https://git-scm.com/docs/git-for-each-ref under "FIELD NAMES" for the possible keys you can pass to --sort in git branch.

Upvotes: 1

Related Questions