在 svn 命令行提交上排除一些文件(不是 svn:ignore)

发布于 2024-12-21 03:10:55 字数 346 浏览 3 评论 0原文

我和很多人一起发展。

我查看远程存储库,得到 3 个文件。编辑后,运行:

svn status

它显示:

M file_1
M file_2
M file_3

现在,我只想提交两个文件:file_1,file_2,但不提交file_3。

怎么做呢?

我不想

svn revert file_3

在提交之前使用。

解释:我编辑 file_1、file_2 以用于共享项目,file_3 仅在我的本地计算机上运行。

I'm developing with many people.

I check out remote repository, get 3 file. After edit, run:

svn status

It shows:

M file_1
M file_2
M file_3

Now, I want to commit only two file: file_1, file_2, but not file_3.

How to do it?

I dont' want to use

svn revert file_3

before commit.

Explain: I edit file_1, file_2 for shared project, file_3 for running on only my local machine.

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

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

发布评论

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

评论(7

半透明的墙 2024-12-28 03:10:55

扩展 zoul 的答案.. 开发文件列表,使用:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "$_ "'

或者,如果您的文件名带有空格,请使用:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "\"$_\" "'

Expanding upon zoul's answer.. to develop your list of files use:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "$_ "'

Or if you have file names with spaces use:

svn stat |  grep -v ignore.file | perl -ne 'chop; s/^.\s+//; print "\"$_\" "'
你列表最软的妹 2024-12-28 03:10:55

怎么样:

$ svn commit file_1 file_2

How about:

$ svn commit file_1 file_2
无言温柔 2024-12-28 03:10:55

bash 的一行:

svn ci $(svn stat | grep -v exclude.file)

one line for bash:

svn ci $(svn stat | grep -v exclude.file)
情绪失控 2024-12-28 03:10:55

只需将要提交的文件的路径附加到 svn commit 命令:

svn commit file_1 file_2

请参阅 http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html

Just append the paths of the files to commit to the svn commit command:

svn commit file_1 file_2

See http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.commit.html

吖咩 2024-12-28 03:10:55

我最终制作了一个包含以下内容的脚本:

svn ci $(svn diff --summarize | \
    grep -v exclude.file1 | \
    grep -v exclude.file2 | \
    ...
    grep -v exclude.fileN \
)

我确信有人可以通过使该脚本读取一个包含要从提交中排除的文件列表的文件来使其更加灵活。

I wound up making a script containing the following:

svn ci $(svn diff --summarize | \
    grep -v exclude.file1 | \
    grep -v exclude.file2 | \
    ...
    grep -v exclude.fileN \
)

I'm sure someone can make it even more flexible by making this script read a file which would contain a list of files to be excluded from the commit.

山色无中 2024-12-28 03:10:55

这是一个 Windows powershell 版本,仅提交不在更改列表中的文件。创建一个名为ignore-on-commit的变更列表(Tortoise SVN无论如何都会理解)并将您不想提交的文件放入其中。

# get list of changed files into targets
[XML]$svnStatus = svn st -q --xml C:\SourceCode\Monad
# select the nodes that aren't in a changelist
$fileList = $svnStatus.SelectNodes('/status/target/entry[wc-status/@item != "unversioned"]') | Foreach-Object {$_.path};
# create a temp file of targets
$fileListPath =  [IO.Path]::GetTempFileName();
$fileList | out-file $fileListPath -Encoding ASCII
# do the commit
svn commit --targets $fileListPath -m "Publish $version" --keep-changelists 
# remove the temp file
Remove-Item $filelistPath

Here's a windows powershell version that commits only files that aren't in a changelist. Create a changelist called ignore-on-commit (which Tortoise SVN will understand anyway) and put the files you don't want to commit into it.

# get list of changed files into targets
[XML]$svnStatus = svn st -q --xml C:\SourceCode\Monad
# select the nodes that aren't in a changelist
$fileList = $svnStatus.SelectNodes('/status/target/entry[wc-status/@item != "unversioned"]') | Foreach-Object {$_.path};
# create a temp file of targets
$fileListPath =  [IO.Path]::GetTempFileName();
$fileList | out-file $fileListPath -Encoding ASCII
# do the commit
svn commit --targets $fileListPath -m "Publish $version" --keep-changelists 
# remove the temp file
Remove-Item $filelistPath
猫腻 2024-12-28 03:10:55

也许你可以使用这个命令。

svn ci `svn st | grep -e "^[A|M]" | grep -v "test.js" | grep -ve "conf\.js$" | awk '{print $2}' | tr "\\n" " "`

maybe you can use this command.

svn ci `svn st | grep -e "^[A|M]" | grep -v "test.js" | grep -ve "conf\.js$" | awk '{print $2}' | tr "\\n" " "`
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文