如何在svn中添加所有未跟踪的文件?像git add -i之类的东西?

时间:2023-01-15 09:32:07

I've been using this long command:

我一直在使用这个长命令:

svn st | awk '/\?/ {print $2}' | xargs svn add

Similarly, to svn rm files I accidentally deleted with normal rm with :

同样,对于svn rm文件,我意外删除了正常的rm:

svn st | awk '/\!/ {print $2}' | xargs svn rm --force

I guess I can write a bash function to do these two, but I'd prefer an interactive add/rm like the one git has.

我想我可以写一个bash函数来做这两个,但我更喜欢像git那样的交互式add / rm。

6 个解决方案

#1


7  

there's an easier line...

有一个更容易的线...

svn add `svn status | grep ?`

then you can set it up as an alias in ~/.bashrc such as

然后你可以把它设置为〜/ .bashrc中的别名,例如

alias svn-addi='svn add `svn status | grep ?`'

#2


6  

I use a generalization of the command line that you run, called svnapply.sh. I did not write it, but I don't remember where I found it. Hopefully, the original author will forgive me for reposting it here:

我使用了您运行的命令行的泛化,称为svnapply.sh。我没有写它,但我不记得我在哪里找到它。希望原作者原谅我在此重新发布:

#!/bin/bash
#
# Applies arbitrary commands to any svn status. e.g.
#
# Delete all non-svn files (escape the ? from the shell):
# svnapply \? rm
#
# List all conflicted files:
# svnapply C ls -l

APPLY=$1
shift

svn st | egrep "^\\${APPLY}[ ]+" | \
sed -e "s|^\\${APPLY}[ ]*||" | \
sed -e "s|\\\\|/|g" | \
xargs -i "$@" '{}'

Per the comments, the script allows you to run arbitrary commands against all files with the same status.

根据注释,该脚本允许您对具有相同状态的所有文件运行任意命令。

Update:

It would not be too difficult to write a script that takes a file path as an argument and prompts the user for add/delete and then does the appropriate thing for that file. Chaining that together with the above script would get you what you want.

编写一个以文件路径作为参数的脚本并提示用户添加/删除然后为该文件执行适当的操作并不困难。将上述脚本链接起来可以得到你想要的东西。

#3


5  

This adds all svn-untracked and -unversioned files in the current directory, recursing through all subdirectories:

这会在当前目录中添加所有svn-untracked和-unversioned文件,并在所有子目录中递归:

svn add --force ./*

Works for me in MacOS 10.6+ and Ubuntu 10+, with svn 1.6+. This does not provide any per-file, user-interactivity; I don't know how to do that.

适用于MacOS 10.6+和Ubuntu 10+,svn 1.6+。这不提供任何每个文件,用户交互性;我不知道该怎么做。

That will also add svn-ignored files, for better or worse.

这也将添加svn-ignored文件,无论好坏。

#4


0  

Use a GUI that can show you all the untracked files, then select all and add. Any decent SVN gui should provide this functionality.

使用可以显示所有未跟踪文件的GUI,然后选择全部并添加。任何体面的SVN gui都应提供此功能。

That said, be careful you really want all those files.

那就是说,小心你真的想要所有这些文件。

#5


0  

TortoiseSVN has the option of showing unversioned files in the Commit and Show Changes dialogs. You can right click a file to 'Add' it or to mark it as ignored.

TortoiseSVN可以选择在“提交”和“显示更改”对话框中显示未版本控制的文件。您可以右键单击文件以“添加”它或将其标记为已忽略。

If you are using Visual Studio: The latest stable version of AnkhSVN has a similar command, but in most cases it only shows the files you should add. (The project provides a list of files to version to the SCC provider; other files are ignored automatically)

如果您使用的是Visual Studio:AnkhSVN的最新稳定版本具有类似的命令,但在大多数情况下,它仅显示您应添加的文件。 (该项目向SCC提供程序提供了版本的文件列表;其他文件将自动被忽略)

#6


0  

There is a similar question which contains a nice Ruby script that gives you the option to add, ignore or skip new files. I've tried it and it worked for me. No GUI needed, only Ruby.

有一个类似的问题,其中包含一个很好的Ruby脚本,可以让您选择添加,忽略或跳过新文件。我试过了,它对我有用。不需要GUI,只有Ruby。

#1


7  

there's an easier line...

有一个更容易的线...

svn add `svn status | grep ?`

then you can set it up as an alias in ~/.bashrc such as

然后你可以把它设置为〜/ .bashrc中的别名,例如

alias svn-addi='svn add `svn status | grep ?`'

#2


6  

I use a generalization of the command line that you run, called svnapply.sh. I did not write it, but I don't remember where I found it. Hopefully, the original author will forgive me for reposting it here:

我使用了您运行的命令行的泛化,称为svnapply.sh。我没有写它,但我不记得我在哪里找到它。希望原作者原谅我在此重新发布:

#!/bin/bash
#
# Applies arbitrary commands to any svn status. e.g.
#
# Delete all non-svn files (escape the ? from the shell):
# svnapply \? rm
#
# List all conflicted files:
# svnapply C ls -l

APPLY=$1
shift

svn st | egrep "^\\${APPLY}[ ]+" | \
sed -e "s|^\\${APPLY}[ ]*||" | \
sed -e "s|\\\\|/|g" | \
xargs -i "$@" '{}'

Per the comments, the script allows you to run arbitrary commands against all files with the same status.

根据注释,该脚本允许您对具有相同状态的所有文件运行任意命令。

Update:

It would not be too difficult to write a script that takes a file path as an argument and prompts the user for add/delete and then does the appropriate thing for that file. Chaining that together with the above script would get you what you want.

编写一个以文件路径作为参数的脚本并提示用户添加/删除然后为该文件执行适当的操作并不困难。将上述脚本链接起来可以得到你想要的东西。

#3


5  

This adds all svn-untracked and -unversioned files in the current directory, recursing through all subdirectories:

这会在当前目录中添加所有svn-untracked和-unversioned文件,并在所有子目录中递归:

svn add --force ./*

Works for me in MacOS 10.6+ and Ubuntu 10+, with svn 1.6+. This does not provide any per-file, user-interactivity; I don't know how to do that.

适用于MacOS 10.6+和Ubuntu 10+,svn 1.6+。这不提供任何每个文件,用户交互性;我不知道该怎么做。

That will also add svn-ignored files, for better or worse.

这也将添加svn-ignored文件,无论好坏。

#4


0  

Use a GUI that can show you all the untracked files, then select all and add. Any decent SVN gui should provide this functionality.

使用可以显示所有未跟踪文件的GUI,然后选择全部并添加。任何体面的SVN gui都应提供此功能。

That said, be careful you really want all those files.

那就是说,小心你真的想要所有这些文件。

#5


0  

TortoiseSVN has the option of showing unversioned files in the Commit and Show Changes dialogs. You can right click a file to 'Add' it or to mark it as ignored.

TortoiseSVN可以选择在“提交”和“显示更改”对话框中显示未版本控制的文件。您可以右键单击文件以“添加”它或将其标记为已忽略。

If you are using Visual Studio: The latest stable version of AnkhSVN has a similar command, but in most cases it only shows the files you should add. (The project provides a list of files to version to the SCC provider; other files are ignored automatically)

如果您使用的是Visual Studio:AnkhSVN的最新稳定版本具有类似的命令,但在大多数情况下,它仅显示您应添加的文件。 (该项目向SCC提供程序提供了版本的文件列表;其他文件将自动被忽略)

#6


0  

There is a similar question which contains a nice Ruby script that gives you the option to add, ignore or skip new files. I've tried it and it worked for me. No GUI needed, only Ruby.

有一个类似的问题,其中包含一个很好的Ruby脚本,可以让您选择添加,忽略或跳过新文件。我试过了,它对我有用。不需要GUI,只有Ruby。