with git svn I can use a svn repository with git. In svn, I can get version of revision with
svnversion
how I can get the version of svn revision with git svn?
git svn info | grep '^Revision: ' | cut -c 11-
git svn info displays some information including the current revision
grep '^Revision: ' extracts from this the line where the current revision is mentioned
cut -c 11- extracts the actual revision number from it by cutting off the first 10 characters which are Revision:
The #Vampire answer is pretty good, I'd just like to include just one more command, in case you want to get the revision of a specific commit, instead the last one of the repository:
git svn log
This command will list all the commits that you have into the SVN repository, giving the SVN revision, author, timestamp, lines edited, and the commit message.
Related
I am trying to migrate a SVN repo to a git. For this I am using git-svn tool. I'm running the command:
git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp
and I'm getting the following error:
Name does not refer to a filesystem directory: Can’t get entries of non-directory at /Applications/Xcode.app/Contents/Developer/usr/share/git-core/perl/Git/SVN/Ra.pm line 312.”
Line 312 of that script is:
$reporter->finish_report($pool);
So I understand that finish_report is failing, but I don't understand why.
That particular section in perl/Git/SVN/Ra.pm is seven years old and part of the initial split of git-svn.perl
Try instead subgit (in its free version, for a one-shot import): it should be more robust.
bzr annotate gives revision numbers of the form a.b.c where a is the revision that was branched off; for our workflow it's more interesting to know in which revision this changed was merged back into the current repo. Can I get bzr to tell me this info?
You can use revision prefix mainline:, see bzr help revisionspec for details.
For example,
bzr revno -r 1.2.3
prints 1.2.3, but
bzr revno -r mainline:1.2.3
prints revision number for revision that merged 1.2.3.
I cloned a large SVN repository (nearly 8,000 commits) and it seems to be OK.
Since then, the commit messages of about 20 Subversion commit messages have been changed to correct a typo. This was done legitimately. However, git svn fetch does not pull the updated commit messages. It still displays the old outdated commit message.
Is there a way to fix this? Preferably in a clean way and without hacking my local git repository too much?
I've tried git svn fetch -r 1234 (where 1234 is a known revision number). But no luck.
from http://git-scm.com/docs/git-svn:
git svn reset
Undoes the effects of fetch back to the specified revision. This allows
you to re-fetch an SVN revision.
[...]
Follow reset with a fetch and then git
reset or git rebase to move local
branches onto the new tree.
So in your case, if revision 1234 is the first one that had its commit message changed, you would do
$ git svn reset -p 1234
$ git svn fetch
If anything is different, including the commit message, then the new commit is a totally different object, with a new SHA1, so as it says, you'll need to rebase any branches you might have onto the appropriate rewritten commit.
How can I do a git svn reset to HEAD revision without specifying the revision number?
It sounds like what you want is not a git svn reset but a simple git checkout. I'm not sure what you mean when you say you reverted to an older revision, but it may have been something like
$ git log
# scan through the log looking for a particular commit.
# You find it and its SHA1 is abc123...
$ git checkout abc123
You are now in 'detached HEAD' state blah blah blah...
Now, HEAD (in your git repository) refers to the commit with SHA1 abc123, whereas HEAD (in the central SVN repository) refers to the newest commit on the SVN repository. If you have things set up in a fairly typical way, then you can just do git checkout master and then git svn rebase and you're back to normal working conditions.
I understand how to initialize a git-svn repo, create a branch, do some work, merge branch, then use git svn rebase and git svn dcommit to push back to the svn repo. But between these two commands, how can you get a status of what is different between the two repos? Something like a git status that tells you that you have x number of files that have been changed.
Just do a diff between your branch and upstream.
git diff --stat git-svn/master..master
Obviously, you'll have to change the branch names to whatever's applicable for your setup.
The only real way I know is to run 'git svn dcommit -n' (or git svn dcommit --dry-run) which will usually give you output like this:
$git svn dcommit --dry-run
Committing to http://yourserver.com/trunk ...
diff-tree bc923cb54847fa340d094c3da1ebd66b8fb0e63e~1 bc923cb54847fa340d094c3da1ebd66b8fb0e63e
diff-tree a05c8be4af7f82dc4de5b4778e2b58203c75eebd~1 a05c8be4af7f82dc4de5b4778e2b58203c75eebd
And then you can 'git show bc923cb54847fa340d094c3da1ebd66b8fb0e63e' to view that diff.