關于Git的使用過程中的一些不必要的文件的提交
作者:邵雄華
第一種方法
1.cd到工程目錄
cd /Users/shaoxionghua/ios/test
2.status一下
git status
(ps:會出現一下類似的東西)
On branch develop
Your branch is up-to-date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .DS_Store
modified: Live.xcworkspace/xcuserdata/shaoxionghua.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit (use "git add" and/or "git commit -a")
3.rm這些不需要的文件或者路徑
git rm --cached .DS_Store
git rm --cached Live.xcworkspace/xcuserdata/shaoxionghua.xcuserdatad/UserInterfaceState.xcuserstate
4.提交這些變更
git commit -m 'ignore'
5.最好執行一下pull和push
git pull
git push
第二種方法
1.cd到工程目錄
cd /Users/shaoxionghua/ios/test
2.修改.gitignore文件
一般常見的一些設置如下:
(ps:在.gitignore文件里面寫入如下內容,不要問我這個文件在哪里,不要問我怎么打開它,方法請自行百度或者google)
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
*.DS_Store
3.提交修改gitignore文件
git rm -r --cached .
git add .
git commit -m 'update .gitignore'