可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Typing svn log
spits out an incredibly long, useless list on a command line. I have no idea why that is the default. If I wanted to read (or even could read) 300 entries on the terminal, I wouldn't mind typing svn log --full
or something similar.
Perhaps the SVN guys are thinking I wanted to feed that output to another program. However, if that is the case, it would make more sense to have the more verbose call for the program - not the terminal user.
Anyway, how do I see just some recent activity like the last 5 or 10 entries to see what changed?
回答1:
limit
option, e.g.:
svn log --limit 4
svn log -l 4
Only the last 4 entries
回答2:
Besides what Bert F said, many commands, including log
has the -r
(or --revision
) option. The following are some practical examples using this option to show ranges of revisions:
To list everything in ascending order:
svn log -r 1:HEAD
To list everything in descending order:
svn log -r HEAD:1
To list everything from the thirteenth to the base of the currently checked-out revision in ascending order:
svn log -r 13:BASE
To get everything between the given dates:
svn log -r {2011-02-02}:{2011-02-03}
You can combine all the above expressions with the --limit
option, so that can you have a quite granular control over what is printed. For more info about these -r
expressions refer to svn help log
or the relevant chapter in the book Version Control with Subversion
回答3:
I like to use -v
for verbose mode.
It'll give you the commit id, comments and all affected files.
svn log -v --limit 4
Example of output:
I added some migrations and deleted a test xml file
------------------------------------------------------------------------
r58687 | mr_x | 2012-04-02 15:31:31 +0200 (Mon, 02 Apr 2012) | 1 line Changed
paths:
A /trunk/java/App/src/database/support
A /trunk/java/App/src/database/support/MIGRATE
A /trunk/java/App/src/database/support/MIGRATE/remove_device.sql
D /trunk/java/App/src/code/test.xml
回答4:
Pipe the output through less
or other pager:
svn log | less
回答5:
To add to what others have said, you could also create an alias in your .bashrc or .bash_aliases file:
alias svnlog='svn log -l 30 | less'
or whatever you want as your default
回答6:
As you've already noticed svn log
command ran without any arguments shows all log messages that relate to the URL you specify or to the working copy folder where you run the command.
You can always refine/limit the svn log
results:
svn log --limit NUM
will show only the first NUM of revisions,
svn log --revision REV1(:REV2)
will show the log message for REV1 revision or for REV1 -- REV2 range,
svn log --search
will show revisions that match the search pattern you specify (the command is available in Subversion 1.8 and newer client). You can search by
- revision's author (i.e. committers username),
- date when the revision was committed,
- revision comment text (log message),
- list of paths changed in revision.
回答7:
But svn log is still in reverse order, i.e. most recent entries are output first, scrolling off the top of my terminal and gone. I really want to see the last entries, i.e. the sorting order must be chronological. The only command that does this seems to be svn log -r 1:HEAD
but that takes much too long on a repository with some 10000 entries. I've come up this this:
Display the last 10 subversion entries in chronological order:
svn log -r $(svn log -l 10 | grep '^r[0-9]* ' | tail -1 | cut -f1 -d" "):HEAD
回答8:
This answer is directed at further questions regarding Subversion subcommands options. For every available subcommand (i.e. add, log, status ...), you can simply add the --help
option to display the complete list of available options you can use with your subcommand as well as examples on how to use them. The following snippet is taken directly from the svn log --help
command output under the "examples" section :
Show the latest 5 log messages for the current working copy
directory and display paths changed in each commit:
svn log -l 5 -v
回答9:
In case anybody is looking at this old question, a handy command to see the changes since your last update:
svn log -r $(svn info | grep Revision | cut -f 2 -d ' '):HEAD -v
LE (thanks Gary for the comment)
same thing, but much shorter and more logical:
svn log -r BASE:HEAD -v