Reputation: 7426
I would like to checkout a specific check-in just by knowing the svn
release number. For example, when I clone a subversion repository to a local git using git-svn clone
, I get the following message:
r5119 = 1563c2dcb9f456d5ba1ba2c277bf7969c452d18b (refs/remotes/git-svn)
M check-svn.c
M Makefile
r5127 = 1b656753fe46287f52f29359793b2d8671137f4b (refs/remotes/git-svn)
M check-svn.c
r5129 = edd06d73d270769cc46db58d9a1a0a4683c95be1 (refs/remotes/git-svn)
M check-svn.c
r5132 = 39bf8333113f1ccc6b839cf944dd88c560509065 (refs/remotes/git-svn)
Checked out HEAD:
https://svn.myserver.net/check-svn r5132
So, we can see that the svn
release tags are known (r5119
, r5127
, ...).
What I would like to do is to get back to an old release of the svn
repository on my local git
clone just by knowing the svn
release number. For example, to do something like:
git checkout r5129
And get the code of the svn
release r5129
in my local git
clone.
My problem is that I don't see how to do this even if I see that the tags are well positioned. For example, when I do a git shortlog
as follow:
git-svn-id: https://svn.myserver.net/check-svn@5119 bb18-a6e4ad0ded21
git-svn-id: https://svn.myserver.net/check-svn@5127 bb18-a6e4ad0ded21
git-svn-id: https://svn.myserver.net/check-svn@5129 bb18-a6e4ad0ded21
git-svn-id: https://svn.myserver.net/check-svn@5132 bb18-a6e4ad0ded21
So, how to do such feature easily (if possible without extra manipulation at the initial cloning) ?
Upvotes: 0
Views: 181
Reputation: 19475
If you don't like the solution with git svn find-rev
, you could try:
git checkout ':/@5127 '
If git is given an string starting with :/
as a revision, it will use the most recent commit where the log message matches the following regular expression. Since git-svn will typically include the revision information in the log message this search can work for that as well. Note the space before the closing quote, that will prevent matching a revision like 51271 if you have that many revisions in the svn history; if you know that the revision you're looking for is recent enough to not have that problem you could leave out the quotes altogether.
Upvotes: 1
Reputation: 7426
First of all, I would like to thank Matthijs P who lead me to the solution with his comment.
git-svn
has a sub-command find-rev
that allow to link a git
hash-tag and an svn
revision label (see the git-svn
manpage for more). So, basically, checking out a specific revision from the remote svn
is done like this:
git checkout `git svn find-rev r5127`
Beware, because you won't be on a branch, so if you perform modifications, it will be difficult to merge (except if you rebase it first).
In my case, this is just a read-only access, so this is fine for me.
Upvotes: 1