讓Git untrack已經進repository的檔案

初學Git的人都知道,可以使用.gitignore來忽略檔案

但如果這個檔案已經進到repository了呢?

一旦檔案已經commit到repository,只把該檔案加到.gitignore的話是沒有用的

還要將那個檔案變成untracked的狀態,這時候可以使用

git rm --cached i-am-a-file-name

將檔案untrack後,並commit這次的異動

再把檔案加到.gitignore

就大功告成了

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s