Difference Between Checkout and Export in Svn

What is the difference between svn import and checkout?

"import" and "checkout" are polar opposites.

"Import" is to bring something completely outside of version control into SVN.

Once something is under SVN control, you can "commit" (new modifications), or "checkout" (stuff you've already committed).

At any time, you can "export" some or all of your project into a "clean directory". The source you've exported is not under version control.

You "import into" and "export out of" SVN.

You "commit" and "checkout" stuff that's already under SVN control.

Subversion - What are the differences between the SVN checkout and SVN update commands?

As I see it, the big difference is that checkout creates a working copy, whereas update brings down changes to an existing working copy.

svn checkout between two revisions on the same branch

You can only check out individual revisions. What you are probably looking to do is export only the files changed between 2 revisions. Pseudocode:

svn diff --summarize -rSTART:END
for each item
svn export URL_TO_ITEM LOCAL_PATH

svn export and commit back to server

If you don't mind doing the svn command twice, you can checkout a single file using this method:

$ svn co --depth=empty http://svn.vegicorp.net/svn/proj
$ cd proj
$ svn up foo.txt
A foo.txt
$ vi foo.txt # Change foo.txt
$ svn commit -m"Modified foo.txt for the heck of it"
sending foo.txt
Transmitting file data .
Committed revision 194833

The --depth=empty checks out your project and creates a working directory. However, it doesn't download any files in that working directory. Then, you can update the files you want which will download only those files. Here I'm downloading foo.txt to edit.

Once you're done, you can commit the changes and you've modified just one file without downloading the entire directory.


One little question

Exactly why are you doing this? I ask because usually when I see something like this, I find out that the build process is doing something wrong sub-opitmally. For example, one site was taking WSDL files, creating the Java source files from the WSDL, and then checking in the generated Java source files. I had to convince them that if they did their build correctly, they'd be automatically generating the Java source files during the build process, and there would be no reason to commit them.

I am not saying it should never be done. For example, you maybe updating a versioning file in this particular context, and want it saved as part of your versioning since the source code will use this file. It's that a process like this usually raises a flag for me. If I knew the reason, I might be able to suggest a better alternative.

How to find out difference between directory and svn checkout?

If you have svn installed, it's very easy: just execute svn status inside the directory in question and it will tell if you if the current folder is a working copy or not.

If you do not have svn installed, you need to check for a .svn folder. Note, however, that since svn 1.7 only the root node of a svn working copy contains the .svn folder.

Update

If you need to check multiple directories at once, you can try this command:

for dir in dirs_to_check; do
svn info && echo $dir
done

This will print out all svn directories. dirs_to_check should be a space-separated list of directories, e.g.

/home/user/proj1 /home/user/proj2 /home/user/proj3

What does SVN checkout do?

svn checkout checks out (retrieves) a working copy of the repository into the specified folder. If you don't have access to the repository, and there's not already a current copy of the source in the folder, you can't possibly do a build.

If there is a current copy of the source there, it should include build.xml.

If you had access to the repository, svn checkout would only retrieve a copy of build.xml if there was one in the repository for the copy being checked out. In other words, it won't magically add a build.xml if one doesn't exist in the repository.



Related Topics



Leave a reply



Submit