Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

android - Eclipse Git gitignore file is ignored

I have an Android project in which I wish GIT to ignore the bin and gen folders. Therefore, I have placed in the directory of the project (I have also tried it at a level higher) the following .gitignore file:

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

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

# Eclipse project files
#.classpath
#.project

Unfortunately, this file is being ignored by Eclipse and I keep committing .class files and files from both gen/ and bin/. I have also tried to mark the folders as "Assume unchanged" but that also does not help.

I am not sure, but it is possible that I have added the file AFTER the first commit.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Seems like you have already added and committed the gen and bin directories. .gitignore works only for untracked files and the purpose of it is to ensure purportedly untracked files remain untracked. To stop tracking bin and gen:

git rm -r --cached bin gen
git commit -m "removed generated files"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...