.gitignore
的檔案secret.txt
$ echo.> .gitignore
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
secret.txt
nothing added to commit but untracked files present (use "git add" to track)
OK,現在我們的.gitignore
裡面沒有放secret.txt
,所以git系統裡面還是可以追蹤到我們的secret.txt
那我們現在把.gitignore
裏面加入secret.txt
$ vim .gitignore
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
nothing added to commit but untracked files present (use "git add" to track)
$ ls -al
total 38
drwxr-xr-x 1 jackey10055206 197121 0 Sep 24 14:05 .
drwxr-xr-x 1 jackey10055206 197121 0 Sep 24 13:45 ..
drwxr-xr-x 1 jackey10055206 197121 0 Sep 24 14:06 .git
-rw-r--r-- 1 jackey10055206 197121 14 Sep 24 14:05 .gitignore
-rw-r--r-- 1 jackey10055206 197121 40 Sep 24 14:02 secret.txt
secret.txt
,但因為我們在.gitignore
裡面有加入secret.txt
,所以git會自動忽略到這個檔案!