美文网首页
iOS 到Github

iOS 到Github

作者: Jack__yang | 来源:发表于2016-08-24 16:08 被阅读23次

(一.ssh的简单使用,二.push一个项目到GitHub)
一.生成ssh

1.首先查看当前MAC的终端有没有安装GIT

根目录下直接输入:git
若显示如下内容,恭喜你已经安装git,不然需要在安装一个git(这里就不细说git的安装过程)
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Forward-port local commits to the updated upstream head
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

2.已知MAC上git,接下来新建SSH-key(用来和github上连接)

终端输入: ssh-keygen -t rsa -C your@mail.com(此处填写Github上的邮箱地址)
然后终端会显示:

#这里以指定key例子(中间一直按Enter键)
Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): 
/home/git/.ssh/id_gitEnter passphrase (empty for no passphrase):
 #密码设置为空,如果设置了密码,客户端使用,需有记住此Key密码的功能
Enter same passphrase again:
Your identification has been saved in /tmp/id_test.
Your public key has been saved in /tmp/id_test.pub.
The key fingerprint is:db:c8:37:24:56:08:b8:c5:d5:8e:f3:60:84:d6:fb:a0 root@i-25BDB9AF
The key's randomart image is:
+--[ RSA 2048]----+
| o.+.. |
| . =.o.. |
| + ..+. |
| . B.. |
| oS*. |
| Eo *o |
| + + |
| . . |
| |
+-----------------+
`到这里就已经生成完了`

3.这时在终端输入:ls -a(可以查看当前所有的文件包括隐藏的,找到.ssh的文件)
接着在终端输入:open .ssh(打开文件,找到id_rsa.pub文件打开,复制里面的文件内容)
4.打开github点击你的头像\settings\SSH and GPG keys\New ssh key 这里的Title (可以随意写)key(把上个步骤复制的粘贴到这里)最后不要忘了Add SSH key.
二.push 一个项目到guthub

1.在Github上新建一个项目;
2.终端中输入:cd 当前项目的目录
3.终端中输入:git init (初始化)
4.终端中输入:git add . (添加)
5.终端中输入:git commit -m"(此处输入与你项目有关的:如XX第一次提交)"
6.终端中输入:git remote add origin(此处填github上clone or downdload/Clone with ssh 上面的地址)

7.终端中输入:git pull origin master
8.终端中输入:git push origin master -f(直接推到github上)

会显示类似如下的内容:

Counting objects: 208, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (204/204), done.
Writing objects: 100% (208/208), 920.10 KiB | 147.00 KiB/s, done.
Total 208 (delta 25), reused 0 (delta 0)
remote: Resolving deltas: 100% (25/25), done.
To git@github.com:XXXXXXXXXXXXX
 + 53d955e...38d2198 master -> master (forced update)
```
这样就已经上传成功了,可以到Github上看到你的项目了。

相关文章

  • iOS 到Github

    (一.ssh的简单使用,二.push一个项目到GitHub)一.生成ssh 1.首先查看当前MAC的终端有没有安装...

  • iOS如何上传代码到Github

    iOS如何上传代码到Github 很多iOS开发者想开源自己的代码或者demo,开源到Github是个不错的选择,...

  • iOS GitHub Top 100 简介

    iOS GitHub Top 100 简介 iOS GitHub Top 100 简介

  • iOS 上传项目到github

    一、 使用SourceTree上传项目 步骤一、步骤1.png 步骤二、image.png 步骤三、image.p...

  • ios 上传项目到GitHub

    配置SSH keys 重启finder,在user里面找到.ssh文件如果存在删除重新生成,终端里输入指令: mk...

  • iOS 上传工程到GitHub

    首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我们使用git...

  • iOS 上传项目到github

    前提 已拥有github账号 1.新建仓库 2.创建后copy地址备用 接下来都是本地库操作 3.可在本地新建文件...

  • 《上传iOS代码到gitHub》

    01.创建一个新的工程。 02.配置项目 03.复制项目地址 04.打开终端 输入命令 1.cd desktop ...

  • iOS 上传项目 到GitHub

    之前在GitHub上一直都是以旁观的角度进行使用,从未想过自己在上面发布过什么,本猿一直都是往里走的人,想着自己有...

  • Github上的iOS App源码

    Github上的iOS App源码 Github上的iOS App源码

网友评论

      本文标题:iOS 到Github

      本文链接:https://www.haomeiwen.com/subject/yxhosttx.html