200 likes | 316 Vues
This tutorial guides students through the fundamentals of using SVN (Subversion) for version control in CS 282. Students will set up their first repository, learn essential commands for adding, committing, and updating files, and collaboration techniques. Key topics include accessing the CSE server, creating directories, importing projects, and managing changes. Additionally, the tutorial addresses common conflicts and best practices for teamwork in programming environments, ensuring that students are well-equipped for collaborative projects using SVN.
E N D
Paired Programming! • Please sit next to your partner. • If you don’t have a partner, please find one now.
Lab 2: SVN Tutorial CS 282
But first… • Questions from last time? • Anything you would like to know about the assignment? • Notes • You should do all your drawing inside DrawGLScene • The completed framework is online for Mac OSX, Linux, and Windows (once OpenGL is installed in ECC). • In order to compile the framework, you must download OpenGL (XCode, apt-get, website).
What is SVN? • SVN is a versioning control software.
Why use SVN? • A repository of files with monitored access to keep track of who and what changes were made to files • Version tracking • Collaboration and sharing files • Historical information • Retrieve past versions • Manage branches
Your First Repository (intro) • Let’s create a repository now. • First, have two terminal sessions up. • The first terminal will be used to access your ECC account (i.e. what you used to log onto the lab computer). • Everything accessed here is considered to be on your “local” machine • This is where your “local copy” is • The second terminal will be used to access your CSE account (i.e. a DIFFERENT account completely separate from your ECC account). • Everything accessed here is considered as being “remotely” accessed on a completely different computer than the ECC computer) • This is where your “repository” is
Your First Repository (intro) • CSE 1) Log into the CSE server in terminal • sshusername@cse.unr.edu • CSE 2) Create a repository directory in CSE • ~/repositories/ • CSE 3) Type in “svnadmin create tutorial” in the repositories directory • This will create a folder in repositories called “tutorial”
Your First Repository (cont’d) • ECC 1) Create a directory you would like to add repository files to. • Let’s name it “myproject” • ECC 2) Add the following folders in myproject • trunk • branches • tags • ECC 3) Now type in the following from one directory up from myproject • svn import myprojectsvn+ssh://username@cse.unr.edu/cs/username/repositories/tutorial • NOTE: this is all one command, and should all be typed onto a single line of the terminal before hitting enter • Replace “username” with your CSE username
Your First Repository (end) • Those directories you just created are now in your repository • Use the import command on your first revision. • ECC 4) Now delete the local directory (myproject) on the ECC side. • rm –frmyproject • ECC 5) Now let’s get the revision stored in the repository. • svn checkout svn+ssh://username@cse.unr.edu/cs/username/repositories/tutorial • NOTE: this is all one command, and should all be typed onto a single line of the terminal before hitting enter • Replace “username” with your CSE username • Congratulations! You have just successfully created and downloaded your first svn repository!
SVN Commands (intro) • First, switch drivers! • ECC 6) Go into tutorial/trunk/ and create a file in it • For example, main.cpp • ECC 7) Commit this to your repository • svn commit –m “[insert meaningful message here]” • ECC 8) Now, use and test the following commands… • Use these commands by typing: svnCommandNameHere • add • Use this when you want to add a file to your repository. • Create a main.h and add it to the repository (don’t commit it yet).
SVN Commands (cont’d) • delete • Use this when you want to remove a file from the repository • Remove main.cpp (don’t commit yet). • status • Use this to check what you’ve changed so far. • “?” – You haven’t added this file yet • NOTE: This is fine. You don’t ALWAYS have to add files that are denoted with a “?”. NEVER ADD YOUR BINARIES (EXECUTABLES). • “A” – You’ve added this file. • “M” – You’ve made changes to this file.
SVN Commands (end) • diff • Check out the exact lines of code you’ve added or removed. • “+” means you’ve added this line, • “-” means you’ve removed this line. • update • Allows you to update to the newest revision. • Have your partner svn checkout (co) the repository on their computer. • Commit the changes you’ve been making. • Have your partner svn update. • Call me when you have completed this step.
Commands to Know and Love • add • add files to your local repository • status • check which files you’ve changed, which files haven’t been added yet • diff • see what’s different between the revision you’re running and the changes you’ve made • delete • remove files from your local repository • commit • commit your changes to the online repository • update • update your local repository with the latest version
Conflicts • Partner A and Partner B both work on the same file, test1.cpp. • Partner A commits his changes to the repository. • Partner B finishes a little later, and tries to commit. • Uh oh! Partner B has encountered a conflict. • SVN will then prompt you with a variety of options to handle this conflict
Resolving Conflicts • In order to resolve conflicts, there are a few things you can do… • Tell SVN to ignore your changes • Tell SVN to ignore your partner’s changes • Manually remove whatever is conflicting, and recommit. • The best way, of course, is to not have a conflict in the first place. • Be sure to google SVN, and take a look at the documentary if you’re having trouble resolving conflicts.
Useful Links • TortoiseSVN (For Windows): http://tortoisesvn.tigris.org/ • RabbitVCS (For Linux):http://www.rabbitvcs.org/