Home > Back-end >  A alias remove local brach and create with same name again
A alias remove local brach and create with same name again

Time:11-10

I need to a alias remove local branch and regenerate with same name again. for example;

grb test-branch

git regenerate branch

will make this automatically

 git branch -D test-branch && git checkout -b test-branch

how can I do this ?

is there any default shortcuts comes with vanilla git ?

CodePudding user response:

You can add the following function to your .bashrc or .zshrc file;

# git branch regenerate
function gbrr () {
    git branch -D "$@" && git checkout -b "$@"
}

and use like And you can use it like below

gbrr feature/navbar
  • Related