(1)在項目中,有些檔案是不能被送出到版本庫的,比如項目的eclipse配置檔案,生成的目标檔案等,這些無用檔案如果送出到版本庫,會給團隊的其他人帶來麻煩,環境的差異導緻項目運作失敗,以及生成的目标檔案是多餘的
(2)我們需要全局設定下,讓git忽略掉這些檔案,首先建立一個文本檔案,輸入以下内容
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.classpath
.project
.settings
target
build
.gitignore
META-INF
(3)找到本地.gitconfig目錄,在同目錄下,複制并粘貼Java.gitignore到該目錄,再打開.gitconfig檔案加下配置:
[user]
name = java1234
email = [email protected]
[core]
excludesfile = C:/Users/Administrator/Java.gitignore
重新開機eclipse restart,如圖所示,即為成功
