commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
Print out list of all branches with last commit date to the branch, including relative time since commit and color coding.
There are 3 alternatives - vote for the best!
This fixes a bug found in the other scripts which fail when a branch has the same name as a file or directory in the current directory.
Simpler and without all of the coloring gimmicks. This just returns a list of branches with the most recent first. This should be useful for cleaning your remotes.
Add this line to your ~/.gitconfig for a git alias "git brd" (i.e., brd = (br)anch+(d)ate) which sorts branches by date. Allows you to pass in limited "git branch" options such as "-r" (remote) or "-a" (all). (Note: forum added "$" prefix to command; obviously in gitconfig there is no "$" prefix.)
If you can do better, submit your command here.
You must be signed in to comment.
Is there a good way to add that to the git alias?
You can't add it as a git alias because it's using a bash for loop to run the command several times. What you can do is add a script at /usr/local/bin/git-branch-dates containing:
#!/bin/bash
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
Git automatically searches through any bash scripts on your path that start with git- so you can now run:
git branch-datesand the script will be run.
Of course you can add it as a git alias!
A git alias which is
"!f() { ...bash script here...; }; f"
works just fine. So, if you add an alias which says
brel = "!f() { 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; }; f"
git brelwill do the proper thing.
Of course, the single command
git for-each-ref --sort=-committerdate --format='%1B[32m%(committerdate:iso8601) %1B[34m%(committerdate:relative) %1B[0;m%(refname:short)' refs/heads/is easier to alias :)