Current commit messages:
commit 6a15c88f851efb900d8799e65373d9472654d0e4 (HEAD -> master)
Author: Taryn
Date: Fri Mar 30 09:27:07 2018 -0700
Foo'd the bar
commit 2c3c44731ef93060ffe69e802ed8d3e2f3c02ca0
Author: Taryn
Date: Fri Mar 30 09:24:13 2018 -0700
Increased the qux
commit 38757810e7da6edec7a16aff0f8ed05d4b699a78
Author: Taryn
Date: Fri Mar 30 09:23:57 2018 -0700
Broke more things
The first step is to append all of the unpublished commit messages with a ticket number:
git filter-branch -f --msg-filter 'cat && echo "\nticket: 12345"' origin/master..HEAD
This changed the commit messages like so:
commit 6a15c88f851efb900d8799e65373d9472654d0e4 (HEAD -> master)
Author: Taryn
Date: Fri Mar 30 09:27:07 2018 -0700
Foo'd the bar
ticket: 12345
commit 2c3c44731ef93060ffe69e802ed8d3e2f3c02ca0
Author: Taryn
Date: Fri Mar 30 09:24:13 2018 -0700
Increased the qux
ticket: 12345
commit 38757810e7da6edec7a16aff0f8ed05d4b699a78
Author: Taryn
Date: Fri Mar 30 09:23:57 2018 -0700
Broke more things
ticket: 12345
Then I wanted to link to all of those commits on github so I needed to find all commits with the previously-appended text:
git log --grep='ticket: 12345' --pretty=format:"%h" --no-abbrev
Which yielded:
6a15c88f851efb900d8799e65373d9472654d0e4
2c3c44731ef93060ffe69e802ed8d3e2f3c02ca0
38757810e7da6edec7a16aff0f8ed05d4b699a78
7148d9fdd4720ccd079da7c4158f17da0aa71b9b
f6439cf231d6add749a7e05cf4bf2ac167ba125e
fbddea1ac36dfe0cfbd6388f2863934f96eef215
b29763e978efb7d527ab3d4992545c0344a3eec8
14a016b037a9b4bcfb47fa73e61fb115c963071f
75432aa3ad87a403b2121627024ef60e59ec90b1
6277c910ff4654c5112b5462e73b8e52241cce0e
11df96600936d817f8a91b4807cf1d346e8c296b
But those are obviously not links so I need to prepend the github url to each of those lines.
$ git log --grep='ticket: 1234' --pretty=format:"%h" --no-abbrev | sed 's|^|https://github.com/phrohdoh/fake/commit/|'
Which then yielded:
https://github.com/phrohdoh/fake/commit/6a15c88f851efb900d8799e65373d9472654d0e4
https://github.com/phrohdoh/fake/commit/2c3c44731ef93060ffe69e802ed8d3e2f3c02ca0
https://github.com/phrohdoh/fake/commit/38757810e7da6edec7a16aff0f8ed05d4b699a78
https://github.com/phrohdoh/fake/commit/7148d9fdd4720ccd079da7c4158f17da0aa71b9b
https://github.com/phrohdoh/fake/commit/f6439cf231d6add749a7e05cf4bf2ac167ba125e
https://github.com/phrohdoh/fake/commit/fbddea1ac36dfe0cfbd6388f2863934f96eef215
https://github.com/phrohdoh/fake/commit/b29763e978efb7d527ab3d4992545c0344a3eec8
https://github.com/phrohdoh/fake/commit/14a016b037a9b4bcfb47fa73e61fb115c963071f
https://github.com/phrohdoh/fake/commit/75432aa3ad87a403b2121627024ef60e59ec90b1
https://github.com/phrohdoh/fake/commit/6277c910ff4654c5112b5462e73b8e52241cce0e
https://github.com/phrohdoh/fake/commit/11df96600936d817f8a91b4807cf1d346e8c296b