在 git 中排除 .svn 文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/821895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Exclude .svn folders within git
提问by johannix
I'm trying to exclude subversion's folders from being tracked by git. I tried a couple different setups for .git/info/exclude, but it doesn't seem to work. I would use git-svn, but it's a pain to request access to get that to work, so I'd rather just work around this by excluding the folders.
我正在尝试从 git 跟踪中排除 subversion 的文件夹。我为 .git/info/exclude 尝试了几种不同的设置,但它似乎不起作用。我会使用 git-svn,但是请求访问权限以使其工作很痛苦,所以我宁愿通过排除文件夹来解决这个问题。
I want to exclude ".svn/entries"
我想排除“.svn/entries”
I've tried adding the following lines to .git/info/exlude: .svn entries .svn/entries entriessvn
我尝试将以下几行添加到 .git/info/exlude: .svn 条目 .svn/entries 条目svn
No matter what I try, .svn entries shows up when I run git status
无论我尝试什么,当我运行 git status 时都会显示 .svn 条目
采纳答案by Jesse Rusak
I think you want to use a .gitignore file in your top-level directory. This will work if you put ".svn/entries" on a line in that file. You might just put ".svn" instead of ".svn/entries" as well.
我认为您想在顶级目录中使用 .gitignore 文件。如果您将“.svn/entries”放在该文件的一行中,这将起作用。您也可以只放置“.svn”而不是“.svn/entries”。
EDIT: See comments. If they files are already being tracked by git, they'll always show up in git status
.
编辑:见评论。如果它们的文件已经被 git 跟踪,它们将始终显示在git status
.
回答by RoloDMonkey
This thread has the correct answer:
这个线程有正确的答案:
Git - Ignore certain files contained in specific folders
What you really need is:
你真正需要的是:
.svn*
回答by cmcginty
Put ".svn" in a ~/.gitexcludes
file. Then tell git about it:
将“.svn”放入~/.gitexcludes
文件中。然后告诉git:
echo '.svn' > ~/.gitexcludes
git config --global core.excludesfile "/home/USER_NAME/.gitexcludes"
(Make sure you change USER_NAME so it points to your home directory)
(确保您更改 USER_NAME,使其指向您的主目录)
回答by harryhazza
This following structure and .gitignore contents worked for me
以下结构和 .gitignore 内容对我有用
- \.git
- \.svn
- \.gitignore
- \.git
- \.svn
- \.gitignore
.gitignore contents
.gitignore 内容
.svn/
.gitignore
回答by tengzhao201
if you want to keep the svn directory.
如果你想保留 svn 目录。
you may run the following first:
您可以先运行以下命令:
for dir in $(find ./ -type d -name \*.svn); do git rm --cached -r $dir; done;
and then run echo ".svn" >>.gitignore
in the root directory
然后echo ".svn" >>.gitignore
在根目录下 运行
回答by Andrew Burns
Do what Casey
suggests, except name the file .gitignore
and put it in the root of your git repo.
按照Casey
建议进行操作,除了命名文件.gitignore
并将其放在 git 存储库的根目录中。
I also like to do a attrib +h .gitignore
so it won't show up in my explorer windows.
我也喜欢这样做,attrib +h .gitignore
这样它就不会出现在我的资源管理器窗口中。
回答by nils petersohn
since every versioned folder has a .svn directory you have to put:
由于每个版本化文件夹都有一个 .svn 目录,因此您必须放置:
*/.svn/*
*/.svn/*
回答by Victor Lazov
Adding .svn to my .gitignore and executing JesseRusak's command did the trick for me.
将 .svn 添加到我的 .gitignore 并执行 JesseRusak 的命令对我有用。
Thanks!
谢谢!