今天在寫一個 maven 的項目,用 git 的時候,發現 .class 文件也會被引用進來,所以搞一個 .gitignore 文件吧。
在 Windows10 下面,用資源管理器打開文件夾,新建文本文件,嘗試重命名為 .gitignore,此時你會發現不能命名,它把 .gitignore 當成后綴了,所以文件名是是空的。
廢話不多說,三種方法。
1,最簡單的一種
命名為
.gitignore.
ok!
2,使用 powershell
重命名文件為 1.txt,按住 shift,點鼠標右鍵。打開 powershell,輸入如下命令:
ren 1.txt .gitignore
3,使用 git 命令行工具
如果你有裝 git bash,重命名文件為 1.txt,右鍵,"Git Bash Here",輸入如下命令:
mv 1.txt .gitignore
maven 的 .gitignore
內容如下:
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
ok,可以繼續快樂地 commit 了!