UnixSVN Man

download UnixSVN Man

of 18

Transcript of UnixSVN Man

  • 7/31/2019 UnixSVN Man

    1/18

    A V V E N T A W O R L D W I D E

    Digitas Project

    Unix and Subversion Startup Manual

    Version 0.3 , December 15th, 2006.

    avVenta WorldWide, IncCosta Rica Center, Metropolitan ParkBarreal, Heredia, Costa Rica

    Phone 506.2938579

  • 7/31/2019 UnixSVN Man

    2/18

    2avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Version Control

    Version Date Person Comment

    0.1 December 1, 2006 Max Leon Initial Draft0.2 December 14, 2006 Jorge Fernndez Added SVN information and some

    formatting to the document.0.3 December 15, 2006 Max Leon Putty colors configuration and some

    minor updates.

  • 7/31/2019 UnixSVN Man

    3/18

    3avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    List of contents

    Version Control ___________________________________________________________ 2List of contents ___________________________________________________________ 3Introduction to SSH _______________________________________________________ 4Unix Commands quick reference______________________________________________ 5Using Unix Commands _____________________________________________________ 6

    ls ____________________________________________________________________ 6touch _________________________________________________________________ 6rm ___________________________________________________________________ 6cat + grep _____________________________________________________________ 7more/less______________________________________________________________ 7ln ____________________________________________________________________ 7find___________________________________________________________________ 7tar ___________________________________________________________________ 8pwd __________________________________________________________________ 8nohup_________________________________________________________________ 8

    Understanding Unix permissions and chmod ____________________________________ 9Users _________________________________________________________________ 9Groups ________________________________________________________________ 9Ownership _____________________________________________________________ 9Permissions ___________________________________________________________ 10Directories ____________________________________________________________ 10chmod _______________________________________________________________ 11Strange numbers... _____________________________________________________ 12

    Understanding Unix directory and file colors in console ___________________________ 13Colors________________________________________________________________ 13*NIX file system________________________________________________________ 13

    Subversion SVN Quick reference _________________________________________ 14

    Subversion commands ____________________________________________________ 15Check out code from a remote repository ____________________________________ 15Basic Subversion Commands______________________________________________ 15Import Code into Subversion ______________________________________________ 17

    Commit your daily work ___________________________________________________ 18

  • 7/31/2019 UnixSVN Man

    4/18

    4avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Introduction to SSH

    SSH stands for secure shell and is now a days the most widely remote administration tool.

    Yes even more than VNC or Remote Desktop. This is basically a remote console encryptedthat will allow to work almost as locally on a remote machine.

    We can use a client to connect from Windows known as PuTTY and while working with Macwe will use the Mac Terminal. Mac OS X underneath is just another UNIX flavor.

    Well for you to access a machine/device through ssh you will need either to open PuTTY,specify the name or IP of the machine and when prompt provide the username andpassword or from the terminal in Mac type ssh user@machine, the effect is almost thesame, once you have successfully authenticate you will be at the shell on the guestmachine. All of the following commands will apply, the flags may vary from one *NIX flavorto another but you can relay on: user@machine:$ man command_I_want_to_use, itwill show you a manual for the command with most of its flags and options. Or,

    user@machine:$ command h / user@machine:$ command help.

  • 7/31/2019 UnixSVN Man

    5/18

    5avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Unix Commands quick reference

    We run the development servers on Linux, as you might know Linux is basically a port of

    UNIX for main frames to 32 bit hardware platform.

    In case you dont have any previous experience with it. It might look a bit like good old DOSbut is far more powerful.

    Ill list all the commands that you might use more frequently, after that Ill set someexamples to get you a better idea of what they do.

    Command DOS equivalent Description and Flaggs

    cd cdcd - will take you to the very previous path you where at. Cd ~$user will take you to thehome of the specified user, cd by it self will take you to your own home folder.

    ls dir

    -l will show the listing in long format with a lot of extra infor, -h with -l will show the size ofthe f ile in human readable format, -a will show all the f iles nad folders including the

    hidden ones.touch

    rm del-f will force the deletion of a file without asking for confirmation, -r will delete recursevly inconjunction with -f will allow to delete folders and their inner content.

    catgrep -i will ignore the case, -r will search recursivly form a specific pathmore output pager, works like cat but will let you navigate by line or page the outputless same as more but will allow navigation back and forward.

    ln-s will create a soft link (shorcut) this should be the only flag you will need since the hard

    links are not very advisable to use in a development enviroment.find find -name will look for the specified name on the command line.

    tar zip in a way

    tar is a unix command to compress information, can be combined with other

    compressiona algorithms. To create a regular tar file -cvf are the standard flags, using zor j will use either bzip or bzip2 to get a higher rate of compression.

    pwdOnce you type this and hit enter, the absolute path where you are standing at the momentwill show on the screen.

    hohup sends a process to run on the background

  • 7/31/2019 UnixSVN Man

    6/18

    6avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Using Unix Commands

    There are also some other commands that are extremely useful, those are | and ,

    these are used to redirect the output of other commands.

    user@machine:$ is more or less the standard when you are looking a console window)

    ls

    user@machine:$ ls

    The result will list the files and folders; most likely there will be some colors involved. Youwill find the color code for this at the appendix.

    Now, if you need to know the size of a specific file, the owner of the file or its permissions,(also a permissions brief resume will be available on the appendix), you will need to typethis:

    user@machine:$ ls -alh file.txtThis will display the whole info about file.txt, something like this will show up

    -rw-r--r-- 1 mleon IT-SUPPORT 2.6M Nov 20 16:00 file.txt

    This means -rw-r--r-- there are 10 fields, the first one is to indicate if it is a directory, it isnot then is black, the following 3 are the permissions of the owner of the file rw- means thatyou can read and write, the next 3 are the permissions of the group rread only, the last 3are for the rest of the world and has the same mleon is the owner of the file IT-SUPPORT isthe group that the file belongs to. Then you have the size in human readable format(because of the h flag), the date and time of creation and the name of the file.

    touch

    user@machine:$ touch file2.txt

    This will simply create an empty file named file2.txt on the specified path, in this casewherever you where standing. This command is also useful went you need to update thedate to a file, so if you touch one file that was already created, this command simplyupdates its modification date to the current date in the server.

    rm

    user@machine:$ rm file2.txt

    This command will delete the file2.txt, in most modern distributions of Linux the system willprompt for confirmation before deletion. Now if you add the f flag it will be deleted withoutrequesting confirmation.If there was a directory name stuff and file2.txt was inside that directory and you try thisuser@machine:$ rm stuff/file2.txt

    The system will not allow you to delete a directory that has content, if you wish to do so youwill need to use the r (recursive) flag, so rm -rfstuff will actually delete de folder and allof its contents including hypothetical directories, subdirectories and files within stuff. So youcan do something like thisuser@machine:$ rm -rf stuff

  • 7/31/2019 UnixSVN Man

    7/18

    7avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    cat + grep

    user@machine:$ cat file.txt | grep i test > search.txtThis seems to be a pretty difficult, high level command, but, we just combined a couple ofcommands a | and a >. Lets go slowly. First we have cat, cat is the command that will

    read the file.txt and show its contents on the screen, instead of that we use a |. The pipeactually redirects the output to another application. In other words we are instructing theshell to read the file.txt and send it to the grep command, (the power and full functionalityand features ofgrep are way out of the scope of this manual but is all about the regularexpressions that are so useful1), the we are asking grep to look for test ignoring the caseso will match test, Test, tEst, or any other combination you can think of, since we are notbeing a bit more specific it will match testing as well or any other word that has test on it.

    OK so we read the file.txt, send it to grep and ask grep to find any matches with test, oncethat process was done with the > we ask the shell to send the results of the reading and thesearch to a new file called search.txt. Now if you cat the search.txt file you will see theresults of the grep command. For further info on grep you can read the man pages, justtype man grep on the shell.

    To sum up, the most important thing about this example is the use ofgrep, the | and the >since you can combine them in very imaginative ways to pull data out of files or commands.

    As a final note, there will be sometimes that grep results can be pretty large, since we canmake pretty simpler and repeatable regular expressions, so please be very careful if you aresending this results to a file, since you can get a larger amount of hard disk space and affectall the others users, and this will impact the server performance.

    more/lessuser@machine:$ more file.txtThis will show the content of file.txt but will let you scroll though it line by line or page by

    page, is quite useful while you are looking for something specific. You can even applysearches through the document, the command less do the same but back and forth instead

    just forward as more does.

    ln

    user@machine:$ ln s code/Pontiac/content/xml/ Pontiac_xmlThis will create a shortcut from code/Pontiac/content/xml to the Pontiac_xml on the homefolder of user. The mayor difference between a shortcut and a soft link is that for the OS theln is transparent will almost treat Pontiac_xml as a real folder directly on the home of userwhile will it be itself on the actual path.

    find

    user@machine:$ find /path/to/where/you/think/the/file/is name file.txtThis command will look for a file named file.txt recursively inside

    /path/to/where/you/think/the/file/is and will display the actual path if it finds it.Quite useful if you dont know where is at and you run it at the root of the file system (seeappendix for details on UNIX file structure).

    1http://www.gnu.org/software/grep/doc/ . Also you should try user@machine:$man grep

  • 7/31/2019 UnixSVN Man

    8/18

    8avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    tar

    user@machine:$ tar cvf stuff.tar stuffThis will basically create one file that will have everything that is inside the directory stuffand will name it stuff.tar, if you need to compress it a bit more you can choose either to add

    the z or j flags to create them. Example: tar zcvf stuff.tar.gz stuff or tar jcvfstuff.tar.bz2 stuffthe compression ratio of these two is actually higher than zip and it canbe open on windows by winrar.

    If you get a tar file and you need to open it then you will have to replace the flag c by x, cstands for create and x for extract. In other words, if you have a project.tar.gz you willneed to run: user@machine:$ tar zxvf project.tar.gz (the v flag is optional, meansverbose but is good to see what is being un-tared). If the file was project.tar.bz2 then tarjxvfwill be the way to go.

    pwd

    user@machine:$ pwd

    This will simply display the path where you are at the moment. The display in this case ismost likely /home/user.

    nohup

    user@machine:$ nohup tar zcvf smith_sonian_library.tar.gz smith_sonian_library&

    This will tarzip the Smith Soninan Library and will do it in the background, the whole idea isfor you either to keep working on the shell while the process runs or for you to be able toclose the shell and let it run until is over without worrying about a broken connection.

  • 7/31/2019 UnixSVN Man

    9/18

    9avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Understanding Unix permissions and chmod

    This is a topic that has been beaten to death both in books and on-line. For some reason, it

    seems that it is one of the most common misunderstandings that people have to face whenlearning how to write and/or configure their first cgi programs. This tutorial aims to clarifythe concepts involved. Note that we will be referring to UNIX in a generic sense in thisarticle. Most of what we are going to discuss here applies to all UNIX flavors (such as Linux,SVR4, BSD, etc.) It is also a good idea to type man chmod to check for the specific detailson your system, too.

    Users

    A UNIX system serves many users. Users are an abstraction that denotes a logical entity forassignment of ownership and operation privileges over the system. A user may correspondto a real-world person, but also a type of system operation. So, in my system, I have user

    'nick' that corresponds to me, but I also have user 'www' which corresponds to theprivileges necessary to operate the local webserver. UNIX doesn't care about what the usermeans for me. It just knows what belongs to any given user and what each user is allowedto do with any given thing (file, program, device, etc) on the system. UNIX identifies eachuser by a User ID (UID) and the username (or login) such as 'nick' and 'www' is just analias to the UID that makes humans more comfortable.

    Groups

    Users can be organized in groups. A user may belong to one or more groups of users. Theconcept of groups serves the purpose of assigning sets of privileges for a given resourceand sharing them among many users that need to have them (perhaps because they are allmembers of a project working team and they all need access to some common projectfiles).

    So, on my system user 'nick' and user 'www' both belong to the group 'perlfect'. This way,they can have some shared privileges over the files for this site. User 'nick' needs them toedit the site, and user 'www' needs them to manage the webserver that will be publishingthe site.

    Ownership

    Every file in UNIX has an owner user and an owner group. So, for any file in the system,user 'nick' may have one of the following ownership relations:- nick owns the file, i.e. the file's owner is 'nick'.- nick is a member of the group that owns the file, i.e. the file's owner group is 'perlfect'.- nick is neither the owner, nor belonging to the group that owns the file

  • 7/31/2019 UnixSVN Man

    10/18

    10avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Permissions

    Every file on the system has associated with it a set of permissions. Permissions tell UNIXwhat can be done with that file and by whom. There are three things you can (or can't) do

    with a given file:read it,write (modify) it andexecute it.

    Unix permissions specify which of the above operations can be performed for any ownershiprelation with respect to the file. In simpler terms, what can the owner do, what can theowner group do, and what can everybody else do with the file. For any given ownershiprelation, we need three bits to specify access permissions: the first to denote read (r)access, the second to denote (w) access and the third to denote execute (x) access. Wehave three ownership relations: 'owner', 'group' and 'all' so we need a triplet for each,resulting in nine bits. Each bit can be set or clear (not set). We mark a set bit by itscorresponding operation letter (r, w or x) and a clear bit by a dash (-) and put them all on

    a row. An example might be rwxr-xr-x; what this means is that the owner can do anythingwith the file, but group owners and the rest of the world can only read or execute it. Usuallyin UNIX there is also another bit that precedes this 9-bit pattern. You do not need to knowabout it, at least for the time being.

    So if you try ls -l on the command prompt you will get something like the following:[nick@thekla src]$ ls -l

    -rwxr-xr-x 1 nick users 382 Jan 19 11:49 bscoped.pldrwxr-xr-x 3 nick users 1024 Jan 19 11:19 lib/-rwxr-xr-x 1 nick users 1874 Jan 19 10:23 socktest.pl

    The first column here shows the permission bit pattern for each file. The third column shows

    the owner, and the fourth column shows the owner group. By the time, the informationprovided by ls -l should be enough for you to figure out what each user of the system cando with any of the files in the directory.

    Directories

    Another interesting thing to note is that lib/ which is a directory, has permissions, too.Permissions take a different meaning for directories. Here's what they mean:- read determines if a user can view the directory's contents, i.e. do ls in it.- write determines if a user can create new files or delete file in the directory. (Note herethat this essentially means that a user with write access to a directory can delete files in thedirectory even if he/she doesn't have write permissions for the file! So be careful with this.)- execute determines if the user can cd into the directory.

  • 7/31/2019 UnixSVN Man

    11/18

    11avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    chmod

    To set/modify a file's permissions you need to use the chmod program. Of course, only theowner of a file may use chmod to alter a file's permissions. chmod has the following syntax:

    chmod [options]mode file(s).

    The 'mode' part specifies the new permissions for the file(s) that follow as arguments. Amode specifies which user's permissions should be changed, and afterwards which accesstypes should be changed. Let's say for example:chmod a-x socktest.pl

    This means that the execute bit should be cleared (-) for all users (owner, group and therest of the world). The permissions start with a letter specifying what users should beaffected by the change; this might be any of the following:u the owner userg the owner groupo others (neither u, nor g)

    a all users

    This is followed by a change instruction which consists of a +(set bit) or -(clear bit) and theletter corresponding to the bit that should be changed.

    Let's see some examples:$ ls -l socktest.pl

    -rwxr-xr-x 1 nick users 1874 Jan 19 10:23 socktest.pl*

    $ chmod a-x socktest.pl$ ls -l socktest.pl

    -rw-r--r-- 1 nick users 1874 Jan 19 10:23 socktest.pl

    $ chmod g+w socktest.pl

    $ ls -l socktest.pl

    -rw-rw-r-- 1 nick users 1874 Jan 19 10:23 socktest.pl

    $ chmod ug+x socktest.pl

    $ ls -l socktest.pl

    -rwxrwxr-- 1 nick users 1874 Jan 19 10:23 socktest.pl*

    $ chmod ug-wx socktest.pl$ ls -l socktest.pl

    -r--r--r-- 1 nick users 1874 Jan 19 10:23 socktest.pl

  • 7/31/2019 UnixSVN Man

    12/18

    12avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Strange numbers...

    You might have encountered things like chmod 755 somefile and of course you will be

    wondering what this is. The thing is, that you can change the entire permission pattern of afile in one go using one number like the one in this example. Every mode has acorresponding code number, and as we shall see there is a very simple way to figure outwhat number corresponds to any mode.

    Every one of the three digits on the mode number corresponds to one of the threepermission triplets. (u, g and o) Every permission bit in a triplet corresponds to a value: 4for r, 2 for w, 1 for x. If the permission bit you add this value to the number of thepermission triplet. If it is cleared, then you add nothing (some of you might notice that infact, the number for a triplet is the octal value corresponding to the three-bit pattern) if youdon't know what an octal value is, it doesn't really matter, just follow the instructions) So ifa file has rwxr-xr-x permissions we do the following calculation:Triplet for u: rwx => 4 + 2 + 1 = 7

    Triplet for g: r-x => 4 + 0 + 1 = 5Tripler for o: r-x => 4 + 0 + 1 = 5Which makes: 755

    So, 755 is a terse way to say 'I don't mind if other people read or run this file, but only Ishould be able to modify it' and 777 means 'everyone has full access to this file'.

  • 7/31/2019 UnixSVN Man

    13/18

    13avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Understanding Unix directory and file colors in console

    Colors

    The colors may vary from one flavor to another but they seem to be quite constant in thesystem V flavors at least, the BSD (like Macs OS Darwin wont show any colors by defaultdoe).Color convention:

    Blue, is a directory. Green, the file is an executable. Red, the file is compress file. Cyan, is not an actual file but a soft link. White is just a file.

    *NIX file system

    The *NIX file system is radically different than other platforms like Microsofts.

    It is design as a tree but the storage units (network, hard drives, external drives, removabledrives, etc., are handle at least from the user point of view as files and folders.

    I know this sound very odd but once you get familiar with it is actually quite useful.

    There are no C:, D: or any other letter for that matter and if you run out of space you canplug another storage unit, link it to a folder, copy the data over and end of story you willhave more space available.

    The basic file structure that is available in every *UNIX flavor to the best of our knowledgeis as follows:

    / This is the very root of the file system, everything else is under it./etc This folder contains all the configuration files for the OS and its services, you

    might think of this in a way as the Windows folder in a Microsoft machine./var You can find all the logging and miscellaneous files for the system./usr Lets say is like Program Files, it holds most of the applications for the users./sbin Is like system32, all the commands that need to administrator of the system,

    /usr/sbin is mostly alike./root The home of the root who is the Administrator of the *NIX system./home It holds all the users folders, is an equivalent for Documents and Settings./dev where all the devices lay, the sound card, video card, optical drives, etc/boot This has all the files that the system uses to boot up.

    /lib Holds all the dependencies to run programs./tmp Quite as it names indicates is the one that holds all the temporary files.

  • 7/31/2019 UnixSVN Man

    14/18

    14avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Subversion SVN Quick reference

    Subversion is a revision control system and it was designed as a CVS replacement. Given a

    general idea of how the system works and all the features it has, we can find that allcommits are truly atomic operations, so if you interrupt a commit operation, this wontcause any inconsistency in the repository. We can have a full access to the revision historyeven went we remove one file. As every file, the directory also has its own version control,so we can move or rename a directory without affecting its revision history. Native supportof binary files. Branching and Tagging are easy. Those features among others make SVN avery powerful revision control tool2.

    SVN Command Description and flags

    svn add Update your working copy. This command should be performed everytime you are about to make a commit.

    svn commit Commit all your changes to the revision control.svn add Add new files to the version control.svn rm Remove files not longer necessary or used.svn status List all files and whether they are:

    - M: modified- A: added- C: in conflict- ?: status unknown

    svn revert Changes your local file to whatever is on the repository.svn log Lists changes log file.svn resolved After you fix a conflict file, you need to use this before you can commit.svn up Update all the content of your working copy with the last revision on

    the server. You can use with the r ### so you can update your codeto a specific revision.

    svn co Checkout a specific project from the SVN repository.

    2 You can find more information about SVN on: http://svnbook.red-bean.com/

  • 7/31/2019 UnixSVN Man

    15/18

    15avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    Subversion commands

    Check out code from a remote repository

    user@machine:$ svn checkout http://svn.collab.net/repos/svn/trunk devORuser@machine:$ svn co http://svn.collab.net/repos/svn/trunk devALSOuser@machine:$ svn+ssh://user@server/svn/gmc dev

    This command will check out a working copy of the subversion source code into a newsubdirectory called dev. Note, this is just an example, checking out the subversion sourcecould take a while, so dont do it. You would generally substitute the URL with the one you

    are trying to access, and change the working directory to something different. On themajority of the commands you can set the --username parameter and the --pasword to helpautomate things, instead of being prompted for them. Once you create a local working copy,your client should really cache that information, however.

    Also you can use Kerberos is your terminal client supports it, by doing:user@machine:$ kerberos it will ask for your network password just once, and after thatyou wont need to give it again until your session dies.

    Basic Subversion Commands

    user@machine:$ svn updateORuser@machine:$ svn up

    ALSOuser@machine:$ svn up r 123Run this in your project directory to get the latest changes from the source control server.svn update -r 123 Run this in your project directory to update to the specific revision 123.

    user@machine:$ svn statusORuser@machine:$ svn stRun this in your project directory, gives you the status of all the files and directories. If itreturns nothing, then you are in sync. M before a file means modified, ? means the file isnot in source control, C means that the file is in conflict, A the files was added to the source

    control and D which means that files is up to be removed from the repository.

    user@machine:$ svn revertThis will revert the changes that you have made to your working copy.

    user@machine:$ svn diff filename.java

    This will show the differences between filename.java and the working copy. This is mostuseful after running an svn stat and seeing that the file is modified. You can then run thiscommand to see what the differences are.

  • 7/31/2019 UnixSVN Man

    16/18

    16avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    user@machine:$ svn revert filename.javaThis will revert all changes you have made to filename.java back to the copy in therepository.

    user@machine:$ svn revert -R *

    This will revert all changes you have made to the entire project back to the repositoryversion.

    user@machine:$ svn -v listThis will list the files in source control for the current workspace directory.

    user@machine:$ svn -v list http://svn.collab.net/repos/svn/trunkThis will list all files in source control at the particular subversion repository URL. Fairlyuseful if you want to see what the structure is before doing a checkout.

    user@machine:$ svn infoGives you info about the current working copy, including the URL of the repository it points

    to, and the last changed date/author.user@machine:$ svn commit -m Adding new function filename.javaCommit the changes in filename.java, and give it a useful message. Using the messages ishighly important down the road when you want to figure out what a particular change did.Make sure you use them, since we do not allow commits with empty commit messages.

    user@machine:$ svn commit -m Adding lots of new functionsUse this function without the filename to commit all changes to all files. This is useful whenyou have a set of changes spanning multiple files.

    user@machine:$ svn logORuser@machine:$ svn log filename.java

    ALSOuser@machine:$ svn log --limit 5 http://svn.collab.net/repos/svn/trunk

    Use this function to take a look at the log messages. The first one is for the entire workingcopy; the second one, returns all the log messages for that file and the last one shows justthe last 5 log messages on a web repository.

    user@machine:$ svn add newfile.javaAdd a file or directory to version control. Note that you still have to commit to actually sendthe file to the source control server. You also can only use this command from within aworking copy directory, meaning if you havent used source control on that directory youwill need to import it first.

    user@machine:$ svn move filename.java newfilename.javaAllows you to rename or move files within source control. You can either use filenames inyour local repository, or you can even pass in two URL locations to have it bemoved/renamed on the server side. This command is the same as doing a copy and then adelete.

    user@machine:$ svn copy MySource MyNewSourceAllows you to copy a file or directory, either with local files, or on the repository using theURL syntax.

  • 7/31/2019 UnixSVN Man

    17/18

    17avVenta Worlwide, Inc. | (506) 293-8579 , (506) 239-5219 | [email protected] | www.avVenta.com

    user@machine:$ svn delete filename.javaDeletes the filename from source control. Note that the filename will still exist in olderrevisions, but will be deleted from the current revision.

    user@machine:$ svn blame filename.javaThis is one of my favorite commands in subversion. This lists out the file, giving the revisionand person who changed every single line in the file.

    Import Code into Subversion

    user@machine:$ svn import -m Importing the files MySource

    http://svn.theserver.net/svnroot/mysourceImports the directory MySource and all files contained within into the subversion server. TheURL can be several levels deep or more.

    Note: once you import a source code directory, you should remove the directory and thencheckout the directory so that you can have a proper working copy. Oh, and back up yourfiles before you delete them. I dont want any nasty emails about how you lost source code.

  • 7/31/2019 UnixSVN Man

    18/18

    18avVentaWorlwide Inc |(506)293-8579 (506) 239-5219| info@avVentacom | wwwavVentacom

    Commit your daily work

    To commit your work to the SVN server, you have to follow the next steps:

    1.)When an Issue is done, we look which files were updated in the process using SVNcommand ($svn status). This command will tell us all the files modified (M), thosewhich arent under SVN control (?) and those which have any conflict (C).

    2.)If you have any files please go through the following process:- Check very carefully which file(s) is(are) in conflict.- How to solve the conflict depends on the kind of file you are dealing with, if youhave a binary file like swf, png, jpeg, etc; and if you are pretty sure and confidentthat your file is the latest file, you should erase all the duplicates (there will somefiles with the r### termination, for example masthead.swf.r2020 those refers to therevision number, these kind of files need to be erased too)- If you are dealing with a non-binary file like a jsp, css, js for example, you will geta conflict inside the file, so you should lock for which lines have any kind of conflict(you will identify those as soon as you get something like inside the code,

    or or any kind of special tag inside the code that you now it not right). Youshould check all the conflict lines and try to get one line that contains all the changesin a right way. Yes, it may be hard, so you might need to find the last person whomodified the file and ask him/her about that change3. After that you should run $svnresolved to that file and be sure that everything was solved in the right way.

    3.)Identify the files that need to be correctly versioned, for example:$GMVS/src/app/jsp/certified/CarFax.jsp$GMVS/src/web/javascript/main.js$GMVS/src/web/flash/logo.swf$GMVS/images/logo.jpg

    4.)Ensure that the files do not contain changes related to issues that are not slated tobe deployed. If these changes exist, the changes MUST be removed (preferably by

    some automated, known-reliable mechanism) before commitment is attempted. Thisis only possible for text files. Binary files cannot be versioned as easily as text files,so ensure that the correct version of the binary file(s) is (are) being deployed.

    5.)Once we have this file list, if we need to add a new one to the repository, we just usethe SVN command to add files (this can be use for one file o for N files usingwildcards - $svn add folder/name*.* - ):$svn add /GMVS/src/app/jsp/certified/CarFax.jsp

    $svn add /GMVS/src/web/javascript/main.js

    $svn add /GMVS/src/web/flash/logo.swf$svn add /GMVS/images/logo.jpg

    6.)To make the final commit, you just have to use the commit command and make sureit has a very clear description of the changes that were made in that commit. We usethe JIRA Issue Number so we can have a better description of the change (using m

    as parameter and the comment, look at the examples). You can use wildcard heretoo (ex. $svn commit folder/name*.* m GMVS-100).$svn commit /GMVS/src/app/jsp/certified/CarFax.jsp/GMVS/src/web/javascript/main.js/GMVS/src/web/flash/logo.swf/GMVS/images/logo.jpg m GMVS-100

    7.)Please make sure that you kept a copy of the revision number that SVN gives you.

    3If you want to see who was the last person who updated the file, just do $svn log v filename.aaaand you will get all the change list of that file.