Xcode 中 Git 的配置与使用

Xcode 中 Git 的配置与使用主要围绕下面几个问题展开阐述:

  • 问题1,如何在Xcode中创建本地代码库,并添加和提交代码到本地代码库?
  • 问题2,如何在Xcode中提交推送给远程服务器代码库?
  • 问题3,如何在Xcode中克隆远程服务器代码库到本地?
  • 问题4,如何使用Xcode获取远程代码库数据,并解决冲突问题?

 

一、如何在Xcode中创建本地代码库,并添加和提交代码到本地代码库?

创建代码库有两种方式:

方式1:新建工程的时候创建

1. 勾选Create Git repository on 

2. 会自动创建隐藏文件源.git文件

 

 

方式2:把现有的工程拷贝到代码库下,再初始化代码库

1. 进入工程目录

cd /Users/Jerry/Desktop/Document/OC练习/05-git

2. 创建并初始化一个源

git init

3. 把工程拷贝到源里面并完成第一次提交

git add .
git commit -m 'First Commit'
 
LinKundeMacBook-Pro-3:/ Jerry$ cd /Users/Jerry/Desktop/Document/OC练习/05-git
LinKundeMacBook-Pro-3:05-git Jerry$ git init
Initialized empty Git repository in /Users/Jerry/Desktop/Document/OC练习/05-git/.git/
LinKundeMacBook-Pro-3:05-git Jerry$ ls -a
.            .git            05-gitTests
..            05-git            05-gitUITests
.DS_Store        05-git.xcodeproj
LinKundeMacBook-Pro-3:05-git Jerry$ git add .
LinKundeMacBook-Pro-3:05-git Jerry$ git commit -m 'First Commit'
[master (root-commit) 71cd1a9] First Commit
 19 files changed, 1058 insertions(+)
 create mode 100644 .DS_Store
 create mode 100644 05-git.xcodeproj/project.pbxproj
 create mode 100644 05-git.xcodeproj/project.xcworkspace/contents.xcworkspacedata
 create mode 100644 05-git.xcodeproj/project.xcworkspace/xcuserdata/Jerry.xcuserdatad/UserInterfaceState.xcuserstate
 create mode 100644 05-git.xcodeproj/xcuserdata/Jerry.xcuserdatad/xcschemes/05-git.xcscheme
 create mode 100644 05-git.xcodeproj/xcuserdata/Jerry.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 05-git/AppDelegate.h
 create mode 100644 05-git/AppDelegate.m
 create mode 100644 05-git/Assets.xcassets/AppIcon.appiconset/Contents.json
 create mode 100644 05-git/Base.lproj/LaunchScreen.storyboard
 create mode 100644 05-git/Base.lproj/Main.storyboard
 create mode 100644 05-git/Info.plist
 create mode 100644 05-git/ViewController.h
 create mode 100644 05-git/ViewController.m
 create mode 100644 05-git/main.m
 create mode 100644 05-gitTests/Info.plist
 create mode 100644 05-gitTests/_5_gitTests.m
 create mode 100644 05-gitUITests/Info.plist
 create mode 100644 05-gitUITests/_5_gitUITests.m
LinKundeMacBook-Pro-3:05-git Jerry$ 

 

 

二、问题2,如何在Xcode中提交推送给远程服务器代码库? 

1. 配置远程服务器代码库名 

 

posted @ 2016-10-29 20:11  穷则独善其身  阅读(2877)  评论(0编辑  收藏  举报