.gitignore設定教學
為什麼要用 .gitignore?
在把資料同步到github時,有時候會同步到一些不必要的檔案。
例如:環境設定( Eclipse的.metadata檔 )、編譯檔( java的.class檔 )…等等
所以,我們可以利用.gitignore檔讓gitHub忽略這些檔案
https://www.toptal.com/developers/gitignore/
然後輸入你有用到的工具、語言
網站會自動幫你判斷這些工具或語言需不需要產生 .gitignore檔
例如: 當我輸入javaScript, html, css時就不會有相對應的選項
因為這些並不會需要忽略的檔案!~
如下所示 我輸入了Eclipse, java, maven, git
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Step2 產生.gitignore檔
按下創建後,會產生下面這份檔案
檔案會根據每個人輸入的工具、語言,而產生不一樣的檔案內容
請在這個檔案上按滑鼠右鍵 –> 另存新檔
檔名請先用預設的
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
下載好之後請打開存放檔案的資料夾
點選上方的檢視 –> 把「副檔名」打勾
那你剛剛產生的檔案就會像我的檔案一樣,顯示出副檔名為.txt
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
然後請將檔案重新命名
請將副檔名.txt也一併刪除
直接改成 .gitignore
如下圖所示
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Step3 將.gitignore檔放到資料夾
最後請將此檔案拉到你要同步的資料夾中
之後用github同步時,github就會讀取這份.gitignore檔
忽略該忽略的檔案~
資料夾應該會長的像這樣
因為設定github同步而產生的.git 以及 .gitignore檔
應該要在同一層
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
完成!~
相關文章連結: