- Checkout code from svn
1
$ svn co --non-interactive --no-auth-cache --username SVN_USER_NAME --password SVN_PASSWORD http://svnserver.domain.com:8080/svn/test_repos/trunk/svn-commands-test .
- Create empty file
1
$ touch test_file
- Add empty file to svn
1
2
$ svn add test_file
A test_file
- Commit and push empty file to svn
1
2
3
4
5
6
$ svn commit -m "empty file"
Adding test_file
Transmitting file data .done
Committing transaction...
Committed revision 23748.
- Add entry to file
1
$ echo "hello world" > test_file
- Check project status
1
2
$ svn status
M test_file
- Commit and push updated file to svn
1
2
3
4
5
$ svn commit -m "added hello world to test file"
Sending test_file
Transmitting file data .done
Committing transaction...
Committed revision 23749.
- Add another entry to file
1
$ echo "new line" >> test_file
- Commit and push updated file to svn
1
2
3
4
5
$ svn commit -m "added new line to test file"
Sending test_file
Transmitting file data .done
Committing transaction...
Committed revision 23750.
- View file change history/log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ svn commit -m "added new line to test file"
svn log test_file
------------------------------------------------------------------------
r23750 | SVN_USER_NAME | 2015-07-16 16:39:23 +0200 (Sun, 16 Jul 2015) | 1 line
added new line to test file
------------------------------------------------------------------------
r23749 | SVN_USER_NAME | 2015-07-16 16:37:56 +0200 (Sun, 16 Jul 2015) | 1 line
added hello world to test file
------------------------------------------------------------------------
r23748 | SVN_USER_NAME | 2015-07-16 16:36:48 +0200 (Sun, 16 Jul 2015) | 1 line
empty file
------------------------------------------------------------------------
- Revert to initial commit r23748
1
2
3
4
$ svn up -r r23748
Updating '.':
U test_file
Updated to revision 23748.
- View log again
1
2
3
4
5
6
$ svn log test_file
------------------------------------------------------------------------
r23748 | SVN_USER_NAME | 2015-07-16 16:36:48 +0200 (Sun, 16 Jul 2015) | 1 line
empty file
------------------------------------------------------------------------
- Revert changes
1
2
3
$ svn update
Updating '.':
At revision 23751.
- Revert by doing a merge to r23748
1
2
3
4
5
6
7
$ svn merge -r HEAD:r23748 test_file
--- Reverse-merging r23750 through r23749 into 'test_file':
U test_file
--- Recording mergeinfo for reverse merge of r23750 through r23749 into 'test_file':
U test_file
--- Eliding mergeinfo from 'test_file':
U test_file
- Commit the revert
1
2
3
4
5
$ svn commit -m "reverted to initial commit"
Sending test_file
Transmitting file data .done
Committing transaction...
Committed revision 23751.
- View log of commits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ svn log test_file
------------------------------------------------------------------------
r23751 | SVN_USER_NAME | 2015-07-16 16:50:43 +0200 (Sun, 16 Jul 2015) | 1 line
reverted to initial commit
------------------------------------------------------------------------
r23750 | SVN_USER_NAME | 2015-07-16 16:39:23 +0200 (Sun, 16 Jul 2015) | 1 line
added new line to test file
------------------------------------------------------------------------
r23749 | SVN_USER_NAME | 2015-07-16 16:37:56 +0200 (Sun, 16 Jul 2015) | 1 line
added hello world to test file
------------------------------------------------------------------------
r23748 | SVN_USER_NAME | 2015-07-16 16:36:48 +0200 (Sun, 16 Jul 2015) | 1 line
empty file
------------------------------------------------------------------------
- Use awk to get only commit messages
1
2
3
4
5
6
$ svn log | awk '/\| [0-9]+ line/{nr[NR+2];next};NR in nr'
reverted to initial commit
added new line to test file
added hello world to test file
empty file