Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

git config commit.template apparently not working

I have set a local commit.template in a git repo I manage with SourceTree. When I commit as 'git commit -a', I get a vi editor with the template file (a hidden file in repo root) correctly loaded, as expected. But SourceTree seems to ignore it, and the commit sheet presents an empty commit text area.

Is there a way to have a commit template in SourceTree?

3 answers

Hi Paolo,

I've just tested this myself and it works fine both from within SourceTree and the command line taking me to vi. I ensured I followed the Git doc guide (rather than doing it my own way). It's better to use $HOME and have a relative link from there rather than an absolute link. So here's what I did:

  1. In the terminal I typed "touch $HOME/.gitmessage.txt"
  2. Then in the terminal I did "open $HOME/.gitmessage.txt" and edited the file typing in anything, in my case the first line was "Author: Kieran Senior" so I knew it was definitely using that file.
  3. In the terminal I went to my repo directory and typed "git config commit.template $HOME/.gitmessage.txt" so it was only set for that repository.
  4. I opened up SourceTree and using that specific repository hit commit and the commit window showed my template.
  5. I then typed in 'git commit -a' as you did in the terminal which opened vi and showed me my template.

So in both instances this worked fine. There's a number of reasons this didn't work for you, the git message template not being found, or not existing, or the correct git setting not being set. Perhaps try step 3 above ensuring that it points to a valid file.

Hope that helps

No, it doesn't help, this doesn't work at all. SourceTree just doesn't honor the commit template. I'm using Windows 8 and neither a custom file name, nor a .git_template.txt file as explained here (https://jira.atlassian.com/browse/SRCTREE-982), nor a .gitmessage.txt. It just doesn't work, or it's broken, or never was implemented, choose the one you like at most. Don't point to "user's dumbness" when lots of people say that this doesn't work.

This worked just fine in OSX.  Thanks!

Same problem here. Windows 7, Sourcetree 1.6.8.0, Git 1.9.4

I'm on Windows and I followed the exact same steps you did, @Kieran Senior [Atlassian]. I just omitted $HOME (but still used a relative path), because I wanted my commit template to be specific to my repository and I want it to propagate to other team members, just like my .gitignore file. 

Here are my steps:

  1. Open Sourcetree and go to the repository.
  2. Click the terminal button. Entered these commands:
    1. touch .committemplate.txt
    2. vi .committemplate.txt
    3. Added the words "test template", saved and closed the file.
    4. git config commit.template .committemplate.txt
  3. Closed the terminal and back to Sourcetree. It now showed .committemplate.txt as an unstaged file with the contents "test template".
  4. Clicked the Commit button.

Expected:

The words "test template" somewhere in the commit message text area.

Actual

The commit message text area was empty.

To verify that the template itself was working, I then performed the following steps:

  1. In Sourcetree, click the terminal button
  2. Entered the following commands
    1. git add .committemplate.txt
    2. git commit

vi came up with the words "test template" filled in. However, exiting the terminal, closing and re-opening the repository or even restarting Sourcetree had no effect - Sourcetree still presents me with an empty commit message.

 

 

Hey Carl. Could you open an issue on jira.atlassian.com and link back to here? Us devs don't really come on AAC any longer due to time constraints. Cheers

I have the same problem where the commit template is showing up fine in a terminal session but not in Source Tree (it's blank).    I've verified/tried the following:

1. The entry in the config file is showing the same in Source Tree as it is in a terminal

        [commit]

                 template = $HOME/.gitcommitmessage.txt

2. I've changed the .gitcommitmessage.txt file to contain nothing but a single word, and that didn't help

3. I tried both --global and non-global when running "git config commit.template $HOME/.gitcommitmessage.txt"

4. I set the config.template to a bogus value and got an error in the terminal, but still blank in SourceTree.

 

It seems SourceTree isn't reading the config.template setting at all even though I see it when I click on "Edit Config File..."

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in DevOps

Introducing Atlassian Open DevOps

Hey Community! I’m Shana, a member of our DevOps team here at Atlassian. I wanted to make sure you saw our announcement last week about the launch of Open DevOps since you may have missed it amidst a...

514 views 2 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you