The text editor 'vim' creates files ending in '.swp' (swap files) for all files that are currently open. We don't want them creeping into the repository. Make this repository ignore '.swp' files.
文本編輯器 'vim' 會(huì)自動(dòng)創(chuàng)建以 '.swp' 結(jié)尾的臨時(shí)交換文件,我們不想讓這些文件進(jìn)入到倉庫,讓倉庫忽略掉這些 '.swp' 文件。
在開發(fā)時(shí)經(jīng)常會(huì)因編輯器、IDE、編譯器或其他什么程序自動(dòng)生成一些臨時(shí)文件、日志文件什么的,這些都不算源代碼,所以不應(yīng)該讓 Git 來管理。
.gitignore 文件存放在倉庫的根目錄下,專用于配置可忽略文件的規(guī)則,它是一個(gè)文本文件,每行書寫一條規(guī)則,常用的規(guī)則舉例如下:
# 忽略掉文件名是 foo.txt 的這個(gè)文件
foo.txt
# 忽略所有 log 文件
*.log
# 但 important.log 是個(gè)例外,不忽略
!imprtant.log
第7關(guān)過關(guān)畫面如下:
http://wiki.jikexueyuan.com/project/githug-walkthrough/images/level-7-ignore.png" alt="第7關(guān) ignore" />