Im am using a simple on-time import to migrate an existing SVN repository to GIT.
$ subgit import --svn-url http://svn/repo repo.git
Everything works fine, but is there any chance to include the corresponding SVN revision number in each GIT commit created by SubGit?
Currently there's no such functionality, but there's something that has similar effect.
When you set up the access to the Git repository, after cloning it you can follow this recommendation from SubGit book. I.e. edit .git/config
file to set
[remote "origin"]
...
fetch = +refs/svn/map:refs/notes/commits
and then run
git fetch
To download the Git notes. After that "git log" will display revision numbers.
Moreover, if you need to find revision number by SHA-1 hash and vice versa from a script, you can run
git log --all --format="%H %N"
The output may look like:
669d570bc561023034c7b28fd6e0a369662b1258
aa628cf9ac100bb144f50490d403e2dcacfd0842 r3624 trunk
db76bb8572f62169a9a28532890610b5a6c234c9
c5b2a475ce5fce72a620064b7b9507af2ec10212 r3623 branches/feature
a5938100859e6d1a245f84907acd33cf8092eb96
086773418197047b523cda6e892441b1364c56f7 r3622 branches/feature
f47b87de14a9d476cd8efd708e0571512875faf9
fb8edc1b9ad1668c1930f8db6f6e43c08d02baa1
64fd8ef37200438dd4068255ff56ac09e73a8259
00cc3cc581593c90155569fadb47c0d99565a362
7ca753c7c8ae572ceff235eb8f68d1e8805f0bc4 r3621 branches/feature
827a04ebede055a6847b52d416efe04b9e81511e r3620 branches/feature
After that you can use grep, awk, sed and other tools you like to find SHA1 by revision and vice versa.
Lines without revision numbers correspond to Git notes themselves (Git notes for commits are stored in other Git commits) and just Git commits not annotated with notes, i.e. not translated from SVN. Empty lines are added after commits with notes because the notes contain LF character at the end; grep and awk are great at ignoring them.
I hope this is more convenient than if the revisions were put directly into the commit message.
Finally I'll add that this all works not only for import but also for continuous synchronization as well.
I'm one of SubGit developers.
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