eclipse中SVN设置
用svn控制版本,svn本身是不会识别哪些该传,哪些不该传,这就导致有些关于路径的东西(比如拓展jar的路径)也被上传了,而当别人下载后,那个路径对于这个人可能完全不存在,项目编译就会出问题。所以,用eclipse安装了svn插件,不能一股脑把android项目都传上去。
- 1、在eclipse里屏蔽不需要提交的文件
Window -> Preferences --> Team -> Ignored Resources![]()
在右侧添加如下文件【bin、 target、m2-target、gen、.classpath、.project】这样在以后提交时,这些都会自动屏蔽掉,不会更新上去。![]()
- 2、在Eclipse中设置忽略的.svn文件夹,此操作仅对此项目有效。
右键 - Properties - Java Build Path - Source - xxx/src - Excluded - 点右边的 Edit,在Exclusion patterns中加入【**/.svn/**】,让Eclipse忽略.svn目录即可。
- 3、在Eclipse的导航视图中,选中尚未加入版本控制的文件或目录,右键 --> Team --> 添加至SVN:ignore 。此操作仅对此项目有效。
![]()
SVN客户端中设置
- 1、在资源管理器中,右键一个未加入版本控制文件或目录,选择TortoiseSVN →Add to Ignore List,会出现一个子菜单,允许你仅选择忽略该文件或者忽略所有具有相同后缀的文件。
如果你想从忽略列表中移除一个或多个条目,右击这些条目,选择TortoiseSVN →从忽略列表删除。![]()
![]()
- 2、通过SVN客户端设置全局忽略列表,它会作用到所有的项目。
右键 --> TortoiseSVN --> 设置 --> 常规设置 --> 在如下输入框中添加![]()
Git客户端创建
一句话:通过开源网站,如github创建库时会自动创建忽略目录文件,你神马都不需要管!
1、在当前工作目录中创建【.gitignore】文件在工作目录的根目录中,创建一个.gitignore文件,向该文件中添加要忽略的文件或目录。注意:在创建或编辑这个文件之前,一定要保证要忽略的文件还没有添加到git索引中。如果添加.gitignore文件前, 要忽略的文件已经存在,可使用命令【git rm --忽略文件名】将要忽略的文件从索引中删除。.gitignore文件的格式规范:
- 所有空行或者以注释符号 # 开头的行都会被 Git 忽略。
- 可以使用标准的 glob 模式匹配。
- 匹配模式最后跟反斜杠(/)说明要忽略的是目录。
- 要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(!)取反。
所谓的 glob 模式是指 shell 所使用的简化了的正则表达式:
- 星号(*)匹配零个或多个任意字符
- [] 匹配任何一个列在方括号中的字符(如[abc]要么匹配一个 a,要么匹配一个 b,要么匹配一个 c)
- 问号(?)只匹配一个任意字符
- 如果在方括号中使用短划线分隔两个字符,表示所有在这两个字符范围内的都可以匹配(如[0-9]表示匹配所有 0 到 9 的数字)
补充说明:
- 工作目录的每一层下级目录都可以有一个.gitignore文件,以说明当前目录下需要被git忽略的文件或目录
- .gitignore文件应该被提交到共享库中,以便能被协作者共享忽略规则
- 通常的做法是,在创建新的Android工程前,会先在github或git@osc创建一个库,这时选择自动创建忽略目录文件,这样以后神马都不需要管了!
2、创建一个全局的.gitignore
可以通过创建~/.gitignore_global并添加到git全局配置以减少每层目录的规则重复定义。使用命令【git config --global core.excludesfile ~/.gitignore_global】即可
3、仅在本地仓库忽略
本地仓库的文件忽略规则可以在【本地仓库/.git/info/exclude】文件中添加。注意, 忽略规则不会提交到共享库中,只对本地有效。![]()
![]()
![]()
Git官方文档
Ignoring files
From time to time, there are files you don't want Git to check in to GitHub. There are a few ways to tell Git which files to ignore.
Create a local .gitignore 推荐使用!
If you create a file in your repository named .gitignore, Git uses it to determine 确定 which files and directories to ignore, before you make a commit.
A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains 维护 an official list of recommended 推荐的官方列表 .gitignore files for many popular operating systems, environments, and languages in the
github/gitignore
public repository.
- In Terminal, navigate to the location of your Git repository.在终端(本地磁盘),导航到到Git库所在位置
- Enter
touch .gitignore
to create a .gitignore file.创建文件If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
git rm --cached
Create a global .gitignore 全局的
You can also create a global .gitignore file, which is a list of rules for ignoring files in every Git repositories on your computer 电脑中的所有库. For example, you might create the file at ~/.gitignore_global and add some rules to it.
- Open Terminal.
- Run the following command in your terminal:
git config --global core.excludesfile ~/.gitignore_global
Explicit repository excludes 明确的库排除
If you don't want to create a .gitignore file to share with others,不想共享忽略文件(仅仅想在自己本地库中忽略) you can create rules that are not committed with the repository 规则不会被提交到库中. You can use this technique 技巧 for locally-generated files 本地生成的文件 that you don't expect other users to generate,不希望其他用户生成 such as files created by your editor.
Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.
- In Terminal, navigate to the location of your Git repository.
- Using your favorite text editor, open the file .git/info/exclude.
附件列表