Skip to content

Convenience script that prints a menu of recent git branches and allows you to switch to a new branch by selecting its corresponding number

Notifications You must be signed in to change notification settings

conorsheppard/git-branches-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Overview

Convenience script that prints a menu of recent git branches and allows you to switch branches by selecting their corresponding number

Setup

Make the script executable using chmod +x branches.sh.

Copy and paste the command below into your terminal to move the script alongside your global .gitconfig file:

cp branches.sh ~/branches.sh

If you would like to run this script as a git alias, add the following alias to your .gitconfig file:

[alias]
...
branches = "!f() { sh ~/branches.sh $1 $2 $3; };f"
...

Then simply execute git branches in any repository to use the script.

Examples

The script can take some command line options.

You can add a number argument to indicate how many branches to show. If omitted, the script will show the default, 10.

./branches.sh 100

You can also add the -g option followed by a string argument which will do a grep on the branch list and only show the matches in the resulting menu.

./branches.sh -g fix

Please note that although the above two can be used in conjunction, the number argument must always come last

./branches.sh -g fix 100
git-branches-script-readme-tutorial.mov

About

Convenience script that prints a menu of recent git branches and allows you to switch to a new branch by selecting its corresponding number

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages