Difference between revisions of "Svn"
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
* svn status --verbose | * svn status --verbose | ||
* svn log = display the history of changes to a file or directory | * svn log = display the history of changes to a file or directory | ||
+ | * svn switch http://svn.example.com/repos/calc/branches/my-calc-branch | ||
+ | ** switch transforms an existing working copy to reflect a different branch | ||
==typical work cycle== | ==typical work cycle== |
Revision as of 20:40, 26 October 2009
Contents
General
- Unlike most version control systems, Subversion's revision numbers apply to entire trees, not individual files.
- Recommended to have three directories in the repository
- a trunk directory to hold the “main line” of development
- a branches directory to contain branch copies
- and a tags directory to contain tag copies.
Getting Started
- svn help <command>
- svn admin create /var/svn/newrepos
- svn import mytree file:///var/svn/newrepos/some/project -m "Initial Import"
- svn list file:///var/svn/newrepos/some/project
- svn checkout [repository location] {[new name of local directory]}
- svn checkout http://svn.example.com:9834/repos/trunk/some/project
- svn checkout file:///var/svn/repos
- svn checkout file://localhost/var/svn/repos
- svn commit button.c -m "Fixed a typo in button.c."
- svn update
- svn status --verbose
- svn log = display the history of changes to a file or directory
- svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
- switch transforms an existing working copy to reflect a different branch
typical work cycle
- Update your working copy.
- svn update
- Make changes.
- svn add
- svn delete
- svn copy foo bar = Create a new item bar as a duplicate of foo and automatically schedule bar for addition
- svn move foo bar = svn copy foo bar; svn delete foo
- svn mkdir blort = mkdir blort; svn add blort
- Examine your changes.
- svn status
- svn diff
- svn diff > patchfile
- Possibly undo some changes.
- svn revert = blow your crappy shit away and get back to a clean copy
- use to undo any scheduled operations, including add
- svn revert = blow your crappy shit away and get back to a clean copy
- Resolve conflicts (merge others' changes).
- svn update
- svn resolve
- Commit your changes.
- svn commit
More commands
- svn log = Shows you broad information: log messages with date and author information attached to revisions and which paths changed in each revision
- svn log -r 5:19 - v
- svn diff = Shows line-level details of a particular change
- svn cat = Retrieves a file as it existed in a particular revision number and displays it on your screen
- svn cat -r 2 foo.c
- svn list = Displays the files in a directory for any given revision
- svn list -v
- svn checkout -r 1729
- svn export [-r revision#]
Letters
- ? - not under version control
- A - add
- C - file has textual conflicts from an update
- U - file was just updated
- D - file is scheduled for deletion
- M - file has local modificaations
Branching and Merging
svn copy http://svn.example.com/repos/calc/trunk \ http://svn.example.com/repos/calc/branches/my-calc-branch \ -m "Creating a private branch of /calc/trunk."
- svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch
- changeset = a collection of changes with a unique name. The changes might include textual edits to file contents, modifications to tree structure, or tweaks to meta data. "A patch with a name you can refer to."
- Compare tree N with tree N-1 derives the exact patch committed.
- "This issue was fixed by r9238"
- run svn log -r 9238 to read about the exact changeset that fixed the bug
- run svn diff -c 9238 to see the patch itself
- svn merge -c 9238 = merge changeset r9238 into your working copy
Merging in changes from the trunk
- First make sure your working copy of the branch is “clean”—that it has no local modifications reported by svn status
- svn merge URL = merge all recent changes from the URL to the current working directory (which is typically the root of your working copy)
- svn status
- look at the changes carefully with svn diff
- build and test your branch
- can always abort the local changes by running svn revert . -R
- svn commit -m "Merged latest trunk changes to my-calc-branch."
- Note: using patch is inferior to merge since patch cannot track changes to directory structure.
Merge your changes back to the trunk
- Merge in all changes from trunk and commit your branch as above
- Get an up-to-date clean (no local edits) working copy of the trunk
- svn merge --reintegrate http://svn.example.com/repos/my_branch
- delete your branch using "svn delete http://svn.example.com/repos/the_proj/branches/my-branch -m "Remove my-branch.""