全局配置
1姻几、根目錄下touch .gitignore_global
2宜狐、在創(chuàng)建的文件中寫入如下內(nèi)容:
# .gitignore_global
.DS_Store
.DS_Store?
*.DS_Store
*/.DS_Store
*/.xcuserstate
*.xcuserstate
3蛇捌、打開根目錄下的.gitconfig
,添加如下內(nèi)容:
[core]
excludesfile = /Users/mac/.gitignore_global
1豁陆、注意:
mac
替換成你自己的電腦名稱
順便把以下內(nèi)容一起寫入:
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
這段文字的意思是給git log
配置一個別名:git lg
柑爸,可以更優(yōu)雅地顯示提交日志盒音,不信你試試。當然祥诽,原有的git log
可以正常使用。
工程配置
1雄坪、在工程目錄下touch .gitignore
2厘熟、在Github上的忽略配置上找到對應(yīng)的忽略配置维哈,寫入.gitignore
其他問題
如果本地或遠端已經(jīng)產(chǎn)生需要忽略的文件,問題仍然沒有得到解決阔挠。
作如下操作:
git rm --cached file_path
git commit -m "xxoo"
git push
注意:
git rm --cached file_path
只是刪除暫存區(qū)的文件飘庄,本地的文件不會刪除购撼,而git rm file_path
則會刪除文件谴仙。