Difference between 'svn update' and 'svn checkout'

1,176 views
Skip to first unread message

Welington Rodrigues Braga

unread,
Nov 11, 2011, 9:12:32 PM11/11/11
to us...@subversion.apache.org
Hi guys,

I've just started to use Subversion a few months ago and I am really
are asking me why I had never used it before but it is not the reason
of my contact. To be honest I am trying to to do a post-commit script
that automatically sincronizes a given workcopy when any of my users
commits their modifications to my repository.

Although it's is ok and working fine (at least in my simples test), I
did not put in production yet because I have a doubt that neither
Subversion manual or Google were able to answer me. I didn't find any
difference beetwen 'svn update' and 'svn checkout' commands which is
the main function of my post-commit script.

Nowadays I'm using 'svn checkout' and it is working, like I said, but
I'm not sure if I'm losing some functionality with this option.

Can anyone help me and answer my question?


regards.

--
Welington Rodrigues Braga
--------------
Web: http://www.welrbraga.eti.br
MSN: welrbraga[*]msn·com
Gtalk: welrbraga[*]gmail·com
Yahoo / Skype:  welrbraga
PGP Key: 0x6C7654EB
Linux User #253605

"Em tudo somos atribulados, porém não angustiados; perplexos, porém
não desanimados; perseguidos, porém não desamparados; abatidos, porém
não destruídos;" - 2Co 4:8,9

Andy Levy

unread,
Nov 11, 2011, 9:41:18 PM11/11/11
to Welington Rodrigues Braga, us...@subversion.apache.org
On Fri, Nov 11, 2011 at 21:12, Welington Rodrigues Braga
<welr...@welrbraga.eti.br> wrote:
> Hi guys,
>
> I've just started to use Subversion a few months ago and I am really
> are asking me why I had never used it before but it is not the reason
> of my contact. To be honest I am trying to to do a post-commit script
> that automatically sincronizes a given workcopy when any of my users
> commits their modifications to my repository.
>
> Although it's is ok and working fine (at least in my simples test), I
> did not put in production yet because I have a doubt that neither
> Subversion manual or Google were able to answer me. I didn't find any
> difference beetwen 'svn update' and 'svn checkout' commands which is
> the main function of my post-commit script.
>
> Nowadays I'm using 'svn checkout' and it is working, like I said, but
> I'm not sure if I'm losing some functionality with this option.
>
> Can anyone help me and answer my question?

svn checkout creates a new working copy.

svn update updates an existing working copy.

Chapter 2 of the manual, "Basic Usage", covers these pretty well. In
particular, "Creating a Working Copy"
(http://svnbook.red-bean.com/en/1.7/svn.tour.initial.html) followed
immediately by "Basic Work Cycle"
(http://svnbook.red-bean.com/en/1.7/svn.tour.cycle.html)

Blair Zajac

unread,
Nov 11, 2011, 10:06:33 PM11/11/11
to Andy Levy, Welington Rodrigues Braga, us...@subversion.apache.org
On 11/11/2011 06:41 PM, Andy Levy wrote:
> On Fri, Nov 11, 2011 at 21:12, Welington Rodrigues Braga
> <welr...@welrbraga.eti.br> wrote:
>> Hi guys,
>>
>> I've just started to use Subversion a few months ago and I am really
>> are asking me why I had never used it before but it is not the reason
>> of my contact. To be honest I am trying to to do a post-commit script
>> that automatically sincronizes a given workcopy when any of my users
>> commits their modifications to my repository.
>>
>> Although it's is ok and working fine (at least in my simples test), I
>> did not put in production yet because I have a doubt that neither
>> Subversion manual or Google were able to answer me. I didn't find any
>> difference beetwen 'svn update' and 'svn checkout' commands which is
>> the main function of my post-commit script.
>>
>> Nowadays I'm using 'svn checkout' and it is working, like I said, but
>> I'm not sure if I'm losing some functionality with this option.
>>
>> Can anyone help me and answer my question?
>
> svn checkout creates a new working copy.
>
> svn update updates an existing working copy.

As Andy said, but there is some special behavior in checkout. If you
run svn checkout on top of an existing working copy it'll work if the
URL is the same as the working copy URLs, but otherwise fail, so this
may explain the behavior you see. But if you did

svn co $URL1 dir
svn co $URL2 dir

the second one would fail.

It's best to do something like this

if test -d dir; then
svn up dir
else
svn co $URL dir
fi

Welington Rodrigues Braga

unread,
Nov 11, 2011, 10:17:36 PM11/11/11
to Blair Zajac, Andy Levy, us...@subversion.apache.org
2011/11/12 Blair Zajac <bl...@orcaware.com>:


Thanks Andy and Blair. I've already understood this part explained on
manual so my doubt is considering that a working copy was created and
populated before, it will only receive changes (never it will send or
commit them) and aI will not modify he URL.

Considering those points. Will the behavious of both be the same or
there are any risk of happen something wrong?

Nico Kadel-Garcia

unread,
Nov 11, 2011, 10:31:04 PM11/11/11
to Blair Zajac, Andy Levy, Welington Rodrigues Braga, us...@subversion.apache.org

Or, if you actually want a pristine working copy with no local edits
left in place:

rm -rf $dir
svn co $URL $dir

I once had a fascinating discussion of a unique local source control
and build system that had been working for some time, but did repeated
"updates" and checkouts that simply did not do what the author thought
it did. Since the system would look for any files with certain
suffixes and process them, neither 'update' nor 'checkout' would be
sufficient to make sure any local config files were cleared. And in
the cases above, neither would clear any files excluded by
'svn:ignore'.

This led to some confusion.

Blair Zajac

unread,
Nov 12, 2011, 1:29:25 AM11/12/11
to Welington Rodrigues Braga, Andy Levy, us...@subversion.apache.org

Yes, generally, there is no subcommand in the Subversion command line client that pulls and pushes data to the Subversion server, all commands are one way for updates, the either update the data in the working copy or the data in the repository. So you have nothing to worry about inadvertently pushing data to the repository with a "update" or "checkout".

Regards,
Blair

Geoff Hoffman

unread,
Nov 12, 2011, 4:12:42 PM11/12/11
to us...@subversion.apache.org
Wellington, are you by any chance trying to update your development server working copy with your post-commit hook?  I'd recommend svn update or svn update --force over checkout simply due to the fact that it only brings changed files, not the whole repository (save network bandwidth, time, etc.)

If the dev server wc is on the same server as your svn it should be as simple as 

cd /var/www/path/to/wc
svn update .

That said, I've never fiddled with hook scripts; only read about them. 

I'd love to see how you did this since I'd use it too... I just haven't gotten around to it.


Bob Archer

unread,
Nov 16, 2011, 9:47:37 AM11/16/11
to Welington Rodrigues Braga, Blair Zajac, Andy Levy, us...@subversion.apache.org
If this is running as a post commit hook on the server, I would favor using Update. It will be much faster and accomplish what you want.

BOb

Reply all
Reply to author
Forward
0 new messages