使用git需要注意的地方
一:.gitignore配置檔案
touch .gitignore 新增
open .gitignore 開啟
git 上傳程式碼時 .gitignore配置檔案用於配置不需要加入版本管理的檔案.
若在配置之前已經提交過,則會出現gitignore並沒有忽略掉我們已經新增的檔案。那是因為.gitignore對已經追蹤(track)的檔案是無效的,需要清除快取,清除快取後文件將以未追蹤的形式出現,這時重新新增(add)並提交(commit)就可以了。 eg:
git rm --cached MakeUpTools.xcodeproj/project.xcworkspace/xcuserdata/fengjuan.xcuserdatad/UserInterfaceState.xcuserstate
git add .
git commit -m "gitignore"
.gitignore配置內容
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xcworkspace
#CocoaPods
Pods
!Podfile
!Podfile.lock
".gitignore" 23L, 261C
二:.DS_Store
.DS_Store(英文全稱 Desktop Services Store)是一種由蘋果公司的Mac OS X作業系統所創造的隱藏檔案。
刪除 .DS_Store
如果你的專案中還沒有自動生成的 .DS_Store 檔案,那麼直接將 .DS_Store 加入到 .gitignore 檔案就可以了。如果你的專案中已經存在 .DS_Store 檔案,那就需要先從專案中將其刪除,再將它加入到 .gitignore。如下:
刪除專案中的所有.DS_Store。這會跳過不在專案中的 .DS_Store 1.
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
將 .DS_Store 加入到 .gitignore 2.echo .DS_Store >> ~/.gitignore
更新專案 3.git add --all
4.git commit -m '.DS_Store banished!'