I'm doing some exploratory work where I will most likely be spending 30 min on several different variations of the same task. I want to track them in git so I can jump back and forth between approaches. And if there are 3 or 6 or 9 branches, I might need some more info than the branch name to tell them apart.
What is the cleanest way to attach a comment to a new branch?
To describe a branch, use git branch --edit-description , edit the opened file, save and exit.
Creating a new branch allows you to isolate your changes from the master branch. If your experimentation goes well you always have the option to merge your changes into the master branch. If things don't go so well you can always discard the branch or keep it within your local repository.
Another method of adding a multi-line Git commit message is using quotes with your message, though it depends on your shell's capacity. To do this, add single or double quotes before typing the message, keep pressing enter and writing the next line, and finally close the quote at end of the message.
The git branch command lets you create, list, rename, and delete branches.
You want branch descriptions:
git branch --edit-description
This will open up your editor and let you attach metadata to the branch. You can extract it with:
git config branch.<branch>.description
A couple of important notes:
This is stored locally. By definition it can't be pushed since it's stored in .git/config
. All the same it works great for this use case.
If you delete the branch, the description will delete as well.
You can push this description into merge commits if you set git config --global merge.branchdesc true
. This means when you issue git merge --log <branch>
, it'll force the branch description into the stock merge commit message. This has a lot of uses. For example, this is how I track topic branch release notes at my employer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With