Deleting a folder from svn repository - linux

I sometimes make mistakes with svn and have folders stuck in my repository. I want to remove these folders but I cannot figure out a way to do this. Keep in mind I am very new with SVN. I am running this command from apple terminal:
sudo svn delete http://www.yourrepository.com/svn/folder
I get the message :
Anthony-Work-Mac-Pro:htdocs APN$ sudo svn delete http://www.yourrepository.com/svn/folder
svn: Could not use external editor to fetch log message; consider setting the $SVN_EDITOR environment variable or using the --message (-m) or --file (-F) options
I have also tried svn delete, and svn rm.
What do I need to do?

Looks like a commit message is required, and you do not have your system configured to launch an editor for you to add one (without specifying on the command line).
Try this:
svn delete http://www.yourrepository.com/svn/folder --message "Deleting"

To avoid similar messages in the future, add something like export SVN_EDITOR="/usr/bin/vim" to your .bash_profile (or something similar for your Mac :))

You can use 2 step delete and commit for this as well. No need to use repository URL.
svn delete filename1 filename2 forldername1
svn commit -m "[Message] Unwanted files and folder."

I use powershell and the command svn list -R to search the repo recursively for folders I want to delete and then pipe the results into findstr or similar, like:
svn list -r HEAD -R | findstr /R /I "\/obj\$/ \/bin\/$" | % { svn delete --force $_ }
This uses regular expressions to search. Each /folder/ you want to find in the repo is separated by a blankspace, not the usual | (bar) character used in regular expresions.
Good idea to try it out first with just:
svn list -r HEAD -R | findstr /R /I "\/obj\$/ \/bin\/$"
Note to be absolutely sure what you are doing before commit.

Related

How to source the files to be added to a git repo from a file?

I want to always add the same files to my git repo, and I thought that having a file of files to add to git would be an easy way to do that.
How can I ask git add to read the files to be added from a file?
It is also easy to use standard cli tools to do this :
# bash:
git add $(cat file)
# xargs is standard on linux, and comes with git-bash on Windows :
cat file | xargs git add
It seems that git add --pathspec-from-file=file is just what I was looking for.
Just make sure that all lines are valid file names. And that none are empty.

Git delete all unmodified files

I am using git in my project at Linux platform. I have plenty of files in a particular directory. I modified some 50 above files in that directory and didn't stage and commit it. I wish to delete all other unmodified files from that directory? Is there a way to do this, using git and Linux Commands?
Not sure why you would want to do this.... but you can:
# Save changes to stash
git stash save
# Remove everything left
rm -rf ./*
# Checkout (restore) all of the changed files
git stash show --stat | grep -v changed | sed -e 's/|.*$//;' | xargs git checkout
# Restore the changes to those files
git stash pop
git reset --hard [HEAD] should work for you repeated
Repeated question How can I discard modified files?
You can also use more simple commands for this purpose:
git clean -Xfd // capital X
git clean -xfd // lower x
It will clean your working directory from the desired files.
Using git clean is what you want. To remove (-x) those files and directories (-d), run:
$ git clean -fdx
If you use the -X option instead of -x, then the files you have told git to ignore will still be kept (e.g., build artifacts). Recent versions of git require either "-f" (force) or "-n" (dry-run) to be specified.
You should run a dry-run first, to show what will happen, but not actually do anything:
$ git clean -ndx
I use this so often, that I have an alias for this (added to your .gitconfig) to check for files that would be deleted when you run git clean. It's also useful to remind me if I've forgotten to "git add" a file that I want to keep.
[alias]
# list files that would be removed via 'clean' (non-destructive)
ifc = clean -ndx
Then, running git ifc (i.e,. "ifc" = "if clean") shows everything that isn't tracked and could be removed, or isn't tracked and should be added.
https://git-scm.com/docs/git-clean

How to ignore .*o*.cmd on a local linux repository?

I would like to ignore all files like .sddr09.o.cmd or .karma.o.cmd etc onto a kernel svn repository.
I try somme commands like :
svn propset svn:ignore '*.cmd' . --recursive
or
svn propset svn:ignore '*.o.cmd' . --recursive
or
svn propset svn:ignore '.*.o.cmd' . --recursive
but no one success to prevent from commit these files.
So I try to use the dontdiff file located in linux/Documentation/dontdiff appending
*.cmd
*.o.cmd
.*.o.cmd
at the end of the file
and I use the following command line :
svn propset svn:ignore -R -F Documentation/dontdiff .
but no more success.
Any Idea ?
You mention in the comments that you've already added these files, so the first step is to undo that. Presumably you used svn add to add the files, so you'll need to use the inverse of that: svn delete.
svn delete --keep-local path/to/file
The --keep-local will tell SVN not to undo any modifications you've made. If you do want to reset the files to their original state (or delete them if they didn't exist before), you can omit the option.
You can confirm this with svn status. The files in question should not have anything in the first column.
After that, you should be able to run the svn ignore commands that you included in your question.

How to get diff between all files inside 2 folders that are on the web?

So I want to compare this folder http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ with this http://svn.boost.org/svn/boost/sandbox/boost/extension/. I want to get a diff file as a result. These folders are under svn control but I'd prefer git styled diff file (like one shown here) I tried git diff but it seems not to work that way for web folders. So how to do the same thing with one command on Linux?
Update:
So we had a great answer. But it works strangely - it seems to me it shows that all files (same files) have all theire contents replaced with very same contents (while I know for sure that there were only like 3-4 code lines changed at all)...
Update 2:
To achieve what I really needed (dif file with only really changed lines, with git styling, on Linux) do:
$ svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2 --native-eol CRLF
$ svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos --native-eol CRLF
$ git diff repos repos2 > fileWithReadableDiff.diff
Once you have the source trees, e.g.
diff -ENwbur repos1/ repos2/
Even better
diff -ENwbur repos1/ repos2/ | kompare -o -
and have a crack at it in a good gui tool :)
-Ewb ignore the bulk of whitespace changes
-N detect new files
-u unified
-r recurse
You urls are not in the same repository, so you can't do it with the svn diff command.
svn: 'http://svn.boost.org/svn/boost/sandbox/boost/extension' isn't in the same repository as 'http://cloudobserver.googlecode.com/svn'
Another way you could do it, is export each repos using svn export, and then use the diff command to compare the 2 directories you exported.
// Export repositories
svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos1
svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2
// Compare exported directories
diff repos1 repos2 > file.diff

Checking changes made before/after installing application?

On Linux, I need to know which files were added/modified/moved/deleted after compiling and installing an application from source code, ie. the command-line, Linux equivalent to the venerale InCtrl5.
Is there a utility that does this, or a set of commands that I could run and would show me the changes?
Thank you.
Edit: The following commands are sort of OK, but I don't need to know the line numbers on which changes occured or that "./.." were updated:
# ls -aR /tmp > b4.txt
# touch /tmp/test.txt
# ls -aR /tmp > after.txt
# diff -u b4.txt after.txt
If you only need to know which files were touched, then you can use find for this:
touch /tmp/MARK
# install application here
find / -newercm /tmp/MARK
This will show you all files whose contents or metadata have changed since you touched /tmp/MARK (including newly added files).
I would personally use something like Mercurial (version control) to do this.
The main reason, is that it is not only effective but it is also clean, since it will only add a hidden directory to the top of the tree where you want to check these changes.
Let's say that you need to know what files changed in /etc/. So before installation (you need to have mercurial installed) you add the directory to mercurial:
cd /etc
hg init
hg add
hg ci -m "adding all files in /etc/ to track them down"
The above will effectively "add" all the files to track them. To verify nothing has changed:
hg st
Should return no files.
If you (or the installation) modifies a file, you should see something like this:
hg st
M foo.sh
The "M" before the file states the given file was modified.
For new files you would see a ? before the file like:
? bar.sh
After you are done and no longer want Mercurial, simple remove the hidden directory:
cd /etc
rm -rf .hg

Resources