清理 svn 签出(删除非 svn 文件)

发布于 2024-10-09 01:16:43 字数 340 浏览 0 评论 0原文

我想删除我的工作副本中 svn 存储库中未知的所有文件。

实际上就好像我刚刚进行了一次干净的结帐,但我不想重新下载所有文件。

我最接近的想法是......

rm -rf `svn st | grep "^?" | cut -d" " -f8`

但这看起来很笨重,我并不完全相信它,因为输出不一致可能会删除 svn 之外的目录。

“svn导出”不是我想要的,因为我没有清理源代码来打包它,我只想删除大部分内容(*.pyc,*.orig,*.rej,svn-commit.tmp,* .swp)。

除了干净的结帐之外,还有更好的方法吗?

Id like to remove all files in my working copy that are not known in the svn repository.

Effectively as if I'd just made a clean checkout, but Id rather not have to re-download all files.

The closest think I've come to this is...

rm -rf `svn st | grep "^?" | cut -d" " -f8`

But this seems clunky and I don't totally trust it since inconsistency in output could remove dirs outside svn.

"svn export" isn't what Im looking for because I'm not cleaning the source to package it, I just want to remove cruft mostly (*.pyc, *.orig, *.rej, svn-commit.tmp, *.swp).

Is there a better way to do this besides making a clean checkout?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

陪你搞怪i 2024-10-16 01:16:43

此处发布的大多数解决方案无法处理带有空格的文件夹。这就是我们使用这个的原因:

svn status --no-ignore | grep '^[?I]' |  sed "s/^[?I] //" | xargs -I{} rm -rf "{}"

Most solutions that are posted here fail to handle folders with whitespaces. This is why we use this one:

svn status --no-ignore | grep '^[?I]' |  sed "s/^[?I] //" | xargs -I{} rm -rf "{}"
温馨耳语 2024-10-16 01:16:43

http://www.cuberick.com/2008 /11/clean-up-your-subversion-working-copy.html

当我希望我的工作副本与存储库相同时,我会这样做:

 svn st | awk '{print $2}' | xargs rm -rf

这将删除与存储库不同步的所有文件。然后只需更新即可恢复您删除的内容并保持最新状态。

svn up

...确保您没有进行任何编辑或添加!更安全的命令可能是:

svn st | grep '?' | awk '{print $2}' |xargs rm -f

...被忽略的文件怎么办?例如

svn st --no-ignore
svn st --no-ignore | awk '{print $2}' | xargs rm -rf
svn st --no-ignore | grep '?' | awk '{print $2}' |xargs rm -f

http://www.cuberick.com/2008/11/clean-up-your-subversion-working-copy.html

Here is what I do when I want my working copy to be identical to the repo:

 svn st | awk '{print $2}' | xargs rm -rf

That will remove all files that are out of sync with the repository. Then simply update to restore things you deleted and get up to date.

svn up

... Make sure that you've no edits or adds! Safer command might be:

svn st | grep '?' | awk '{print $2}' |xargs rm -f

... What about ignored files? E.g.

svn st --no-ignore
svn st --no-ignore | awk '{print $2}' | xargs rm -rf
svn st --no-ignore | grep '?' | awk '{print $2}' |xargs rm -f
别再吹冷风 2024-10-16 01:16:43
svn status --no-ignore | grep '^[?I]' | awk '{print $2}' | xargs rm -rf

让我解释一下。

获取存储库中文件的状态并将它们一一打印到标准输出到数组中

svn status

这包括设置为通常被 svn 忽略的文件

--no-ignore

匹配包含 ? 的行或“我”作为一种状态。我的意思是一个被忽略的文件和?表示不受 svn 控制的文件。

| grep '^[?I]'

这将打印数组中的第二个变量,即文件名

| awk '{print $2}'

这将删除具有打印文件名的文件

| xargs rm -rf

干杯,
环形

svn status --no-ignore | grep '^[?I]' | awk '{print $2}' | xargs rm -rf

Let me explain.

Get the status of the files in a repository and prints them out one by one to standard output into an array

svn status

This includes files set to normally be ignored by svn

--no-ignore

Match lines that include either a ? or a I as a status. I means an ignored file and ? means a file not under svn control.

| grep '^[?I]'

This prints the second variable in the array which is the filename

| awk '{print $2}'

This removes the files with the printed filesnames

| xargs rm -rf

Cheers,
Loop

蔚蓝源自深海 2024-10-16 01:16:43

使用这个:

svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf

commandlinefu 获取。

Use this:

svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf

Obtained from commandlinefu.

忆沫 2024-10-16 01:16:43

删除所有不具有只读属性的文件?确保你没有事先检查过东西...

Delete every file that doesn't have the readonly attribute? Make sure you don't have things checked out beforehands...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文