Android知识iOS学习程序员

标准的Android git和HG的忽略文件是什么样的呢?

2016-08-25  本文已影响213人  孤独狂饮

什么是忽略文件?

当我们在使用 git 和 HG 管理项目文件的时候,会生成很多的文件,但是这些临时文件并不需要我们提交到我们的服务器去,因此就会使用到忽略文件。

忽略文件的作用?

当我们用的不好的时候,就会在提交的时候,有很多凌乱的信息,导致我们提交错误或者冲突。最极端的情况就是把一些需要频繁改动的文件提交到服务器,会造成经常冲突,因此我们需要一份标准的忽略文件。

通用的忽略文件

以下提供两种忽略文件的模板,满足大部分需求。

1. git 的忽略文件模板:

请在项目的根目录下创建或者修改这个文件: .gitignore 即可。git相关管理工具会 自动识别该文件,帮我们自动忽略掉不需要的文件。如果我们有其他文件也不用提交的画,可以参考下面的样式添加进去即可:

 *~
 .DS_Store

 # Android Studio
 *.iml
 .idea
 .gradle

 build

 
 # Created by .ignore support plugin (hsz.mobi)
 syntax: glob

 ### Android template
 # Built application files
 *.apk
 *.ap_

 # Files for the ART/Dalvik VM
 *.dex

 # Java class files
 *.class

 # Generated files
 bin/
 gen/
 out/

 # Gradle files
 .gradle/
 build/

 # Local configuration file (sdk path, etc)
 local.properties

 # Proguard folder generated by Eclipse
 proguard/

 # Log Files
 *.log

 # Android Studio Navigation editor temp files
 .navigation/

 # Android Studio captures folder
 captures/

 # Intellij
 *.iml
 .idea/workspace.xml

 # Keystore files
 *.jks
 ### Eclipse template

 .metadata
 tmp/
 *.tmp
 *.bak
 *.swp
 *~.nib
 .settings/
 .loadpath
 .recommenders

 # Eclipse Core
 .project

 # External tool builders
 .externalToolBuilders/

 # Locally stored "Eclipse launch configurations"
 *.launch

 # PyDev specific (Python IDE for Eclipse)
 *.pydevproject

 # CDT-specific (C/C++ Development Tooling)
 .cproject

 # JDT-specific (Eclipse Java Development Tools)
 .classpath

 # Java annotation processor (APT)
 .factorypath

 # PDT-specific (PHP Development Tools)
 .buildpath

 # sbteclipse plugin
 .target

 # Tern plugin
 .tern-project

 # TeXlipse plugin
 .texlipse

 # STS (Spring Tool Suite)
 .springBeans

 # Code Recommenders
 .recommenders/

 # Mobile Tools for Java (J2ME)
 .mtj.tmp/

 # Package Files #
 *.jar
 *.war
 *.ear

 # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
 hs_err_pid*
 ### Example user template template
 ### Example user template

 # IntelliJ project files
 .idea
 out
 gen
2. HG/Mercurial 的忽略文件模板:

HG (Mercurial) 的标准忽略文件。这是早期比较好的项目管理工具,但是随着git 的用户群体庞大,git越来越灵活,简单易用,因此 HG也就慢慢退出了我们的视线。最有名的 github 里面也大量使用到git。但是作为一种管理工具,在不同的环境场景下,也可能需要使用HG,尤其是公司的备份管理等,都十分的安全。使用方式很简单,在主项目的根目录下 创建或者修改: .hgignore 文件即可。 这个文件也可以直接放到mode 里面去。 这里提供忽略文件如下:

# Created by .ignore support plugin (hsz.mobi)
syntax: glob

### Android template
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/


# Keystore files
*.jks
### Eclipse template

.metadata
tmp/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath
.recommenders

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# JDT-specific (Eclipse Java Development Tools)
.classpath

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Example user template template
### Example user template

# IntelliJ project files
.idea
*.iml
out
gen
上一篇下一篇

猜你喜欢

热点阅读