04 ecilpse中配置git忽略專案配置檔案和目標檔案
阿新 • • 發佈:2021-07-30
(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,如圖所示,即為成功
(4)只顯示該顯示的檔案