Git and Xcode

  1、web site "New Repository"

  2、为本地 git 管理的项目添加 Repository

$ cd ~/ProjectName
$ git remote add origin https://github.com/userName/xxx.git $ git push -u origin master  # 第一次提交需要 -u,以后执行提交可以简化不再需要 -u。(原因:第一次提交不但会把本地的 master 分支内容推送到远程新的 master 分支,还会把本地的 master 分支和远程的 master 分支关联起来。)

  3、为非本地 git 管理的项目添加 Repository

$ cd ~/Project
$ git init    # 初始化,并在当前目录下出现一个名为 .git的目录

# 注意:如果某些文件没有必要提交的,请先创建 .ignore 文件,否则对 已经被跟踪或者 commit 的文件再放进 .gitignore 会失效。

$ git add .    # 将给目录下所有不包含在 .ignore 的文件提交
$ git commit -m "Initial commit"
# reopen xcode, Source Control was enable

# 执行第二步 "为本地 git 管理的项目添加 Repository"
# create Repository and copy repository address, Xcode.Preferance.Accounts add repository

    关于 .ignore 请参考 ref

  4、Xcode project 在创建的时候,就勾选上使用本地 git 管理。

    也需要执行第二步 “为本地 git 管理的项目添加 Repository”,以后才能在 Xcode -> Source Control -> push。

  5、拷贝他人的 git project

$ git clone repository address
原文地址:https://www.cnblogs.com/eileenleung/p/3493210.html