Android Studio下Svn忽略文件配置的几种方法

(一)新建项目的时候Android Studio向导会创建两个.gitignore,对应的,我们创建两个.svnignore就可以了。里面配置信息可以参考.gitignore,具体配置信息可以参考

github推荐的.gitignore写法


# built application files
*.apk
*.ap_
 
# files for the dex VM
*.dex
 
# Java class files
*.class
 
# built native files
*.o
*.so
 
# generated files
bin/
gen/
 
# Ignore gradle files
.gradle/
build/
 
# Local configuration file (sdk path, etc)
local.properties
 
# Proguard folder generated by Eclipse
proguard/
 
# Eclipse Metadata
.metadata/
 
# Mac OS X clutter
*.DS_Store
 
# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids


http://myshittycode.com/2013/12/02/intellij-configuring-svn-ignored-files/

SOLUTION 2: Add Ignored Files Using IntelliJ

Based on the example above, there are 5 things we need to ignore:-

  • epicapp-ear/target/ directory
  • epicapp-war/target/ directory
  • target/ directory
  • .idea/ directory
  • *.iml files

So, in IntelliJ…

  1. Select “Changes” tab at the bottom.
  2. Select “Local” subtab.
  3. Click on “Configure Ignored Files” button.
  4. In “Configure Ignored Files” dialog, click on the “+” button.
  5. Add the ignored file (or directory).

  6. Repeat step 4 and 5 until all ignored files are added.

SOLUTION 3: Add Ignored Files Directly in .idea/workspace.xml

If you have quite a few files and directories to ignore, the above solution can be rather tedious.

So, an alternative solution is to “hack” .idea/workspace.xml by entering all the ignored paths under “ChangeListManager” component:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <component name="ChangeListManager">
        ...
        <ignored path="epicapp-war/target/" />
        <ignored path="epicapp-ear/target/" />
        <ignored path=".idea/" />
        <ignored path=".settings/" />
        <ignored path="target/" />
        <ignored path=".DS_Store" />
        <ignored path=".classpath" />
        <ignored path=".project" />
        <ignored mask="*.iws" />
        <ignored mask="*~" />
        <ignored mask="*.bak" />
        <ignored mask="*.log" />
        <ignored mask="*.iml" />
    </component>
    ...
</project>
In this example, we ignore all  target  folders, all IntelliJ generated files, all Eclipse generated files, all OS-specific generated files and some useless files.
When we save  .idea/workspace.xml , IntelliJ immediately detects a change made to this file (because it is intelligent) and it will prompt us to reload the project. Once reloaded, the “Configure Ignored Files” dialog will reflect the changes made.

(四)全局配置或者通过命令行实现

http://sdesmedt.wordpress.com/2006/12/10/how-to-make-subversion-ignore-files-and-folders/

Global exclude

With the global exclude we can exclude a certain type of file of being added to any repository to which a certain client connects. To do this, you must edit the Subversion “config” file which you can find in your local Application Data folder. A typical location for this file is: “C:\Documents and Settings\[username]\Application Data\Subversion”.

When you open this file, look for the section [miscellany]. In this section find a line with global-ignores and remove the “#” signes in front of it (if you haven’t removed them allready). Now add the files signatures you want to ignore.

For example, to ignore the suo files, we would write:


global-ignores = *.suo


大意是配置C:\Users\<UserName>\AppData\Roaming\Subversion下面的config文件,增加global-ignores = *.suo 表示所有项目都忽略后缀名为.suo的文件

Local exclude

The local excludes are made on folders. This means you can tell subversion clients to ignore a specific file, type of file or folder. This is done by setting the svn:ignore property on the target folder with the signature of the file or folder to ignore.

For example, to ignore suo files in the solution’s folder, you would perform following command in the folder of the solution:

[TargetFolder]>svn propset svn:ignore *.suo .


大概意思是:在目标目录执行上面的命令,可以忽略目录下所有.suo文件


Do not forget the final dot, it means that the target folder is the current folder. With the above command Subversion will ignore all files with extension “suo” in the target folder.

To ignore folders we have a similar syntax. To ignore for eample a folder “bin” in our target folder execute following command:

[TargetFolder]>svn propset svn:ignore bin .

大概意思是:在目标目录执行上面的命令,可以忽略bin目录


Again, do not forget the final dot, it means that the target folder is the current folder.

To ignore multiple types of files and folders, you must have a newline delimited list of values for the svn propset command. Because this can not be done with the commandline (well, I do not know how to do it anyway), we create a text file with on each line the signature of a file and/or folder to ignore.
For example, we have a textfile with following content:

obj
bin

We save this file in the target folder and name it “ignore.txt”, and then issue the command in the target folder

[TargetFolder]>svn propset svn:ignore -F ignore.txt .



大概意思是:将需要忽略的文件或目录写到ignore.txt,在目标目录执行上面的命令即可忽略

Again, do not forget the final dot, it means that the target folder is the current folder. With the above command all folders with names obj and bin in the target folder will be ignored by Subversion.



你可能感兴趣的:(android,SVN,Studio,.gitignore,.svnignore)