eeejay
eeejay

Reputation: 5894

Simple SVN commands

Seemingly lame question, but I've been through all the docs and tutorials and am unable to figure out exactly what I want.

My repo is https://sourcerepo.something/mystuff

My working folder is
/var/www

I copy new files into
/var/www (that are not under source control since they are new)

I revise some files in
/var/www (that are already under source control)

What command would I use to add new and updated files?
What command would I use to subsequently commit?

The command

svn add /var/www/

will add all files, even the unchanged files that are already under source control. I get a thousand messages warning that the files are "already under source control"

What commandline would I use to just add new and updated files?

Thanks so much.

Upvotes: 1

Views: 236

Answers (5)

Fasani
Fasani

Reputation: 5759

I have the perfect little gem for you.

svn status | grep "^?" | awk '{print $2}' | xargs svn add

This basically says do "svn status" then get all the NEW fils marked as "?" bunch them together and then do an "svn add" on the list.

After that you just need to do your commit.

Upvotes: 0

Gareth McCaughan
Gareth McCaughan

Reputation: 19981

You can make "svn add" shut up by passing the "-q" or "--quiet" flag. As well as not complaining about unchanged files, it will then also not tell you about the ones it is adding, but you can do "svn status" to see what it's done.

No need to add updated files -- "add" means to make files version-controlled that weren't before. "svn commit" will automatically commit the changes you've made to already-version-controlled files.

Upvotes: 0

Michael Dillon
Michael Dillon

Reputation: 32392

Just use

svn add newfilename

Later when you next commit, they will be added to the repository. If you do this a lot it might be a good idea to make a shell alias or script that does the copy and svn add for you.

Upvotes: 1

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181450

I would recommend:

$ svn status

Will give you status of all files, including those that need to be added.

$ svn add /var/www/only/new/files

And finally:

$ svn commit

Upvotes: 3

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272717

Use svn --force to force it to do this. Note that you don't add modified files, you simply commit the changes.

Be careful, though. Doing a blanket add is a good way to end up with all sorts of crud in your SVN repository.

Upvotes: 0

Related Questions