-->

Git alias to add prefix to name of new branch

2019-08-10 00:54发布

问题:

Is there a way to write an alias that adds current date to name of new branch?

For example:

git branch-today new_branch_name

should create new branch with 22_09_2015_new_branch_name name.

回答1:

Create a git alias and add it to your .gitconfig

[alias]
        branch-today = "!bt() { git branch $(date +%d-%m-%Y)_$1;}; bt"

git branch-today foo

Git branch output:

  22-09-2015_foo
* master