Whenever I split a subdirectory into a branch via git subtree split
or (consequently?) when I push a subtree upstream, the commit messages in the new branch/upstream commits have "-n" and a newline prepended to them.
It's easiest to demonstrate with split:
git init repo
cd repo
mkdir splitme
touch splitme/foo
git add splitme/
git commit -m 'Add foo'
git subtree split -P splitme -b splitme-only
From this, I get:
$ git log master
commit 6d5164076bd88d1dab8963d91ec013372e58a444
Author: me
Date: Fri Jul 26 12:22:27 2013 -0500
Add foo
and
$ git log splitme-only
commit 6ce8124a0b5e52d4bba198144d2f3f664d7b19e7
Author: me
Date: Fri Jul 26 12:22:27 2013 -0500
-n
Add foo
As you can see, the "splitme-only" branch has "-n" prepended to the commit message. This is particularly bad as github collapses everything but the first line by default. Hence, you can't easily skim these commit messages on github.
I've tried using --annotate
to maybe get something more readable, but that just appends something to the "-n" line.
The behavior is identical for subtree push
.
Is there any way to prevent the "-n" line from being added? I could rebase the line out, but when I played around with that it broke subtrees merging. Am I doing something wrong?
Using git 1.8.3.4 on OS X 10.8.4.
Use git subtree split to extract the files you want to the an intermediate branch in your repository (you have already done this).
git subtree split lets you specify a rev other than HEAD. ' git push '(man) lets you specify a mapping between a local thing and a remot ref. So smash those together, and have git subtree push let you specify which local thing to run split on and push the result of that split to the remote ref.
Adding a subtreeSpecify the prefix local directory into which you want to pull the subtree. Specify the remote repository URL [of the subtree being pulled in] Specify the remote branch [of the subtree being pulled in] Specify you want to squash all the remote repository's [the subtree's] logs.
On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.
It turns out it's a bug in git, introduced in 1.8.3.3.
Specifically, this merge made subtree run via sh
instead of bash
, which breaks this line.
Here's the bug report I just submitted: http://thread.gmane.org/gmane.comp.version-control.git/231213
UPDATE: The bug is fixed in git 1.8.4
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