使用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!'




猜你喜欢

转载自blog.csdn.net/haixing_zfj/article/details/73547204