1.控制台cd到项目目录下,输入命令:git init
2.在git server创建xxx/project_name.git,输入命令:git --bare init
3.本地控制台:
git add .
git commit -m "first Commit"
git remote add origin [email protected]:tingkongwanli/git.git
git push -u origin master
4.这样就创建成功了,可以在xcode添加git,然后checkout下来(第一次),以后有更新从master pull下来最新代码
5.new a branch,然后可以写你自己部分的代码了。写完后可以commit(local)
注释:merge from branch----从其他地方合并到我的branch
merge into branch----把我的代码合并到其他branch
6.push:用于最终发送到server。切换回master,merge from branch,把最新修改的branch代码合并到master上,最后push上server上面
参考:http://www.jianshu.com/p/103d74b69a13
注意出现Git ignore UserInterfaceState.xcuserstate问题:
1.建立.gitignore,作用是让git忽略自定义规则;
2.项目目录下,新建.gitignore
touch .gitignore
open .gitignore
3..gitignore中输入
*.xcuserstate
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
.DS_Store
4.在命令行输入:
$ git rm --cached path/to/.DS_Store
$ git rm --cached *.xcuserstate
提交:
$ git add .gitignore
$ git commit -m "Remove and ignore .xcuserstate and .DS_Store files."
这时候在xcode进行merger,会提示commit:
控制台输入命令:
git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
再merge,成功
注意:要切换到出问题的branch下才能找到UserInterfaceState.xcuserstate,要不会报错
标签:git,--,XCODE,IOS,branch,commit,xcuserstate,gitignore From: https://blog.51cto.com/u_15740686/5745306