使用Git时如何将不需要提交的文件加入忽略列表(How to add files that do not need to be submitted to the ignore list when using Git)

在java开发中使用Eclipse或是ant  、gradle 对项目编译时,会生成很多不需要提交到仓库的文件或文件夹。

如:像 target、build 目录。像 .class 、或是某些测试文件等。

那么如何控制使git知道哪些文件不需要提交呢,方法是有的。

一、在使用Git CheckOut 的目录中找到【.git】文件夹,在同级目录下增加一个名字为【.gitignore】的文本文件。

内容如下:

/Source/src/myProject/target
/Source/src/myProject/build
/.gitignore

二、进入到【.git】文件夹中,创建一个名字为【tgitchangelist】的文本文件。

内容如下:

<ignore-on-commit>
Source/src/myProject/lib/myFunction1.jar
Source/src/myProject/lib/myFunction2.jar
————————

Using eclipse or ant in java development   、 When gradle compiles the project, it will generate many files or folders that do not need to be submitted to the warehouse.

Such as target and build   catalogue image  . Class, or some test files.

So how to control and make git know which files do not need to be submitted? There are some methods.

1、 Using Git   CheckOut   Find the [. Git] folder in the directory of, and add a text file named [. Gitignore] in the directory of the same level.

The contents are as follows:

/Source/src/myProject/target
/Source/src/myProject/build
/.gitignore

2、 Enter the [. Git] folder and create a text file named [tgitchangelist].

The contents are as follows:

<ignore-on-commit>
Source/src/myProject/lib/myFunction1.jar
Source/src/myProject/lib/myFunction2.jar