git-extras icon indicating copy to clipboard operation
git-extras copied to clipboard

list/checkout recently used branches

Open mgaitan opened this issue 5 years ago • 3 comments

Hi. I have a little script that parse git reflog to look for recently used branches. It's similar to git checkout @{-n} but more user-friendly.

For example,

(nao) mgaitan@morochita:~/nao$ git recent-branches 
1 - feature/PSO-20131-refactor-to-avoid-package-s-interdependency
2 - feature/PSO-20723-include-ut_utils-only-in-development-installations
3 - feature/PSO-20130-move-model-s-related-tests
4 - develop
5 - develop_fixed
6 - master
7 - 48b39f6e31d0181af828fe2b660fc109d4aeb9d4
8 - master_fixed
9 - feature/PSO-20130-move-model-s-related-tests__

(nao) mgaitan@morochita:~/nao$ git recent-branches 2
Switched to branch 'feature/PSO-20723-include-ut_utils-only-in-development-installations'
Your branch is up-to-date with 'origin/feature/PSO-20723-include-ut_utils-only-in-development-installations'.

Here is my implementation, in python https://gist.github.com/mgaitan/ba1e4e252b90a7fd4a4eb9e1742e94fb

Could it be useful in this package? I could rewrite it in bash, if it was needed.

mgaitan avatar Mar 21 '19 13:03 mgaitan

Maybe we could add it once there are enough people vote for it.

spacewander avatar Mar 22 '19 02:03 spacewander

not sure if the intent is to list those that you most recently checked out, but listing them like so is plenty good for me:

git branch -vv --sort=-committerdate

which i bound to the alias git bra

elonderin avatar Oct 13 '20 17:10 elonderin

@elonderin that's a useful command but it's not exactly the same because recent-branch it's sorted by "last checkout date" instead "last commit date" .

mgaitan avatar Oct 13 '20 18:10 mgaitan