Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf ·...
Transcript of Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf ·...
![Page 1: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/1.jpg)
CSCI 2132: Software Development
Subversion (and Git)
Norbert Zeh
Faculty of Computer Science Dalhousie University
Winter 2019
![Page 2: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/2.jpg)
Version Control Systems
A version control system allows us to
• Record the history of changes to the source code of some software we are writing (and many more)
• Maintain multiple versions of the (software) product
• Coordinate the work by multiple team members via • Multiple branches • Support for merging from different branches
Two main types of VCS:
• Centralized: one central repository (RCS, SCCS, VCS, Subversion, ...)
• Distributed: multiple distributed repositories (Git, Darcs, Mercurial, ...)
![Page 3: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/3.jpg)
Version Control Using Subversion (SVN)
A simplified view:
• Backups: Create backups ina repository
• History: “Time machine”, labelled versions
• Collaborative, central repository:Different users can contributeand merge changes
Files, directories
Working copy 1
Files, directories
Working copy 3
Files, directories
Working copy 4
Files, directories
Working copy 2
SVN repository
![Page 4: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/4.jpg)
SVN Checkout
• Create an initial working copy:
$ svn checkout
or
$ svn co
SVN repository
![Page 5: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/5.jpg)
SVN Checkout
• Create an initial working copy:
$ svn checkout
or
$ svn co
Files, directories
Working copy
SVN repository
![Page 6: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/6.jpg)
SVN Add
• Creating files in the working copy does not add them to subversion!
• svn add adds them to SVN’s list of files to manage
• The SVN repository does not know about the added file yet!
+ newfile.txt
Working copy
SVN repository
$ svn add newfile.txt
![Page 7: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/7.jpg)
SVN Commit
• svn commit saves local changes to the repository.
• Local working copy is kept.
• Local working copy can then be deleted without affecting the repository.
• svn commit requires a log message that documents the changes that were made in this commit.
$ svn commit -m”Added newfile.txt”
newfile.txt
Working copy
SVN repository
![Page 8: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/8.jpg)
SVN Commit
• svn commit saves local changes to the repository.
• Local working copy is kept.
• Local working copy can then be deleted without affecting the repository.
• svn commit requires a log message that documents the changes that were made in this commit.
$ svn commit -m”Added newfile.txt”
$ cd "..; rm -r WorkingCopy
SVN repository
![Page 9: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/9.jpg)
newfile.txt
Working copy 1
SVN repository
Working copy 2
SVN Update
• SVN does not allow you to commit changes unless your local copy has an up-to-date view of the repository, including changes others may have committed from their working copies.
• svn update updates your local copy according to the current state of the repository.
• This may create conflicts that you may have to resolve before committing your changes.
• The chance for conflicts increases the longer you work without running svn update. ⟹ Run svn update periodically.
![Page 10: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/10.jpg)
SVN Update
• SVN does not allow you to commit changes unless your local copy has an up-to-date view of the repository, including changes others may have committed from their working copies.
• svn update updates your local copy according to the current state of the repository.
• This may create conflicts that you may have to resolve before committing your changes.
• The chance for conflicts increases the longer you work without running svn update. ⟹ Run svn update periodically.
newfile.txt
Working copy 1
SVN repository newfile.txt
Working copy 2
![Page 11: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/11.jpg)
(Re)moving files
• Moving a file will not move it in the repository.
• Removing a file will not remove it from the repository.
• SVN complains about the missing file the next time we try to run svn commit.
• svn rm removes the file from the repository.
• svn mv renames or moves the file within SVN’s file tree.
• Changes will take effect when running svn commit next.
![Page 12: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/12.jpg)
SVN Troubleshooting
• Do not interrupt an SVN operation (unless it’s hung, takes very long).(This may leave SVN in a corrupt state.)
• Helpful commands: svn info, svn status -v, svn log -v
• A working copy contains a hidden .svn directory, which stores administrative information about the working copy.
• Resolve problems by moving or removing a working copy and checking out a new copy.
• If you allow SVN to save your password, you can remove it withrm ~/.subversion/auth/svn.simple"/*.
![Page 13: Subversion (and Git) Dalhousie University Winter 2019nzeh/Teaching/2132/Slides/subversion.pdf · SVN repository Working copy 2 SVN Update • SVN does not allow you to commit changes](https://reader035.fdocuments.in/reader035/viewer/2022071015/5fcdd44f23cc3b4b6f60fa48/html5/thumbnails/13.jpg)
SVN and Git
• Many version control systems(SCCS → RCS → CVS → Subversion, Git, Mercurial, Darcs, …).
• SVN and Git are the most popular representatives of two competing philosophies:
• SVN (RCS, CVS, …): One centralized repository
• Git (Mercurial, Darcs, …): Fully distributed, no centralized repository
• More on Git later.
• Git can be used in a subversion-like manner:
• svn co ≈ git clone
• svn add ≈ git add
• svn commit ≈ git commit + git push
• svn update ≈ git pull