A small command line tool for creating and naming new topic branches in a consistent way.
create a new-branch script in a folder somewhere in your path.
touch ~/path/to/your/folder/new-branch
Change the mode of the file to make it executable
chmod +x /path/to/your/folder/new-branch
in a new shell check everything is working. Running which new-branch
should output the script location if the folder you created the script in is exported into your path.
→ which new-branch
/path/to/your/folder/new-branch
The tool needs a default branch from which it can create the topic branch. This can be passed with the -b
flag or exported as an environment variable into your shell. In this example our stable development branch is called develop
so we export that to our shell session.
export DEFAULT_BRANCH=develop
The tool does not require but works best when a JIRA_PREFIX
environment variable is also set. This will automatically embed the JIRA project into your branch name
export JIRA_PROJECT=ESPI
new-branch
or to pass a custom target branch
new-branch -b master
This will prompt you to enter an issue type:
~~~~~~~~~~~~~~~~~~~~~
ISSUE - TYPES
~~~~~~~~~~~~~~~~~~~~~
1. feature
2. fix
3. chore
4. refactor
5. test
6. docs
Enter issueType [1 - 5]
then the JIRA issue number and also a short branch description.
After entering this information the tool will checkout the default branch you specify in your environment variable, pull the latest changes and create a branch based off the HEAD of your stable development branch. THe branch will now have all the information about the issue baked in to the name.