GitHub 建立远程仓库

终端所有信息:

Last login: Fri Aug 14 08:58:01 on console

wuxiaoyuan:~ lan$ ls -al ~/.ssh

ls: /Users/lan/.ssh: No such file or directory

wuxiaoyuan:~ lan$ mkdir .ssh

wuxiaoyuan:~ lan$ cd /Users/lan/.ssh

wuxiaoyuan:.ssh lan$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

Generating public/private rsa key pair.

Enter file in which to save the key (/Users/lan/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /Users/lan/.ssh/id_rsa.

Your public key has been saved in /Users/lan/.ssh/id_rsa.pub.

The key fingerprint is:

d6:62:85:4f:43:b1:60:4b:85:be:8d:43:3b:48:04:0c [email protected]

The key‘s randomart image is:

+--[ RSA 4096]----+

|  Eo..  +o+.     |

|    . .o.= .     |

|     . .o =      |

|      . o= .     |

|     . oS=o      |

|      .o*..      |

|         o       |

|                 |

|                 |

+-----------------+

wuxiaoyuan:.ssh lan$ pbcopy < ~/.ssh/id_rsa.pub

wuxiaoyuan:.ssh lan$ cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDIUvEB2QI2ygbbnIkbKCBqTq1eYLb+uQV4ZFioNOqF1DNHh7tIFGl5UPEuFL+hqhz4rWANjisEv3zaBgXCgUlFPP9jOy0QlUN03K+nVVWzj++Jte0e3drD1MDwOAyV1ShD6sy8gsQp9mplnUn0QqS3zdlVe2otrSpfGPpPnD5L/Sv7uV27xszv8vJd73p2Wyayn4cIQ3rHmmvdOWbeQbvN54nGZBUFFt6KIdwLAQ0+ZeLCJavYoL8Ts2PsyzzSPmyHWUfneCpPrBY8CDkYQC3tsftt7ouKSNFURx/hU5eDzdAgu20pNUPasAZLk76VedhhijBU2i9P5OyQXtuwraTDDv2ih5rwvXKG7KgSMdA2UALDOtPF/mF2rftWY4XR7YzOXnsT+i4BXEVs+wmQ0JBMAyo05dCVzIVxglMc8ZEmCOATqFEgbtmqu+eX1DzudTSvQWsp8oO/he2J5g895yEKAXadiXB9VJKsL7Alaf2gNcmT+zD2/MakGtZJKvXDA7x99Ll2aWbbUtJkgpl1F6LFm7MrFG5xshj8cx7JMgq8muTcI+NZiW5c2NNA+6I/5zJwqXyUzhc6Ehl0ek4l6E8khedsywhcmgQQjwd3nXbDqQA1+of3ADCIOCGnvS1ARi3lgRTSFVBi+HwN35a3ZP3lWn+sFgkrPsVbBkiNzd9YWw== [email protected]

wuxiaoyuan:.ssh lan$ ssh -T [email protected]

The authenticity of host ‘github.com (192.30.252.129)‘ can‘t be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.

Are you sure you want to continue connecting (yes/no)?

Host key verification failed.

wuxiaoyuan:.ssh lan$ ssh -T [email protected]

The authenticity of host ‘github.com (192.30.252.128)‘ can‘t be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘github.com,192.30.252.128‘ (RSA) to the list of known hosts.

Hi wusang! You‘ve successfully authenticated, but GitHub does not provide shell access.

wuxiaoyuan:.ssh lan$ cd /Users/lan/Desktop/张三

wuxiaoyuan:张三 lan$ git clone https://github.com/wusang/lanou02.git

Cloning into ‘lanou02‘...

remote: Counting objects: 5, done.

remote: Compressing objects: 100% (4/4), done.

remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0

Unpacking objects: 100% (5/5), done.

Checking connectivity... done.

wuxiaoyuan:张三 lan$ git status

fatal: Not a git repository (or any of the parent directories): .git

wuxiaoyuan:张三 lan$ cd /Users/lan/Desktop/张三/lanou02

wuxiaoyuan:lanou02 lan$ git status

On branch master

Your branch is up-to-date with ‘origin/master‘.

Changes to be committed:

(use "git reset HEAD <file>..." to unstage)

new file:   lanou02/lanou02.xcodeproj/project.pbxproj

new file:   lanou02/lanou02.xcodeproj/project.xcworkspace/contents.xcworkspacedata

new file:   lanou02/lanou02/AppDelegate.h

new file:   lanou02/lanou02/AppDelegate.m

new file:   lanou02/lanou02/Base.lproj/LaunchScreen.xib

new file:   lanou02/lanou02/Base.lproj/Main.storyboard

new file:   lanou02/lanou02/Images.xcassets/AppIcon.appiconset/Contents.json

new file:   lanou02/lanou02/Info.plist

new file:   lanou02/lanou02/ViewController.h

new file:   lanou02/lanou02/ViewController.m

new file:   lanou02/lanou02/main.m

new file:   lanou02/lanou02Tests/Info.plist

new file:   lanou02/lanou02Tests/lanou02Tests.m

wuxiaoyuan:lanou02 lan$ open.

-bash: open.: command not found

wuxiaoyuan:lanou02 lan$ open .

wuxiaoyuan:lanou02 lan$ git add .

wuxiaoyuan:lanou02 lan$ git commit -am "添加了工程"

[master 41b1085] 添加了工程

13 files changed, 762 insertions(+)

create mode 100644 lanou02/lanou02.xcodeproj/project.pbxproj

create mode 100644 lanou02/lanou02.xcodeproj/project.xcworkspace/contents.xcworkspacedata

create mode 100644 lanou02/lanou02/AppDelegate.h

create mode 100644 lanou02/lanou02/AppDelegate.m

create mode 100644 lanou02/lanou02/Base.lproj/LaunchScreen.xib

create mode 100644 lanou02/lanou02/Base.lproj/Main.storyboard

create mode 100644 lanou02/lanou02/Images.xcassets/AppIcon.appiconset/Contents.json

create mode 100644 lanou02/lanou02/Info.plist

create mode 100644 lanou02/lanou02/ViewController.h

create mode 100644 lanou02/lanou02/ViewController.m

create mode 100644 lanou02/lanou02/main.m

create mode 100644 lanou02/lanou02Tests/Info.plist

create mode 100644 lanou02/lanou02Tests/lanou02Tests.m

wuxiaoyuan:lanou02 lan$ git push

warning: push.default is unset; its implicit value is changing in

Git 2.0 from ‘matching‘ to ‘simple‘. To squelch this message

and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to ‘matching‘, git will push local branches

to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative ‘simple‘

behavior, which only pushes the current branch to the corresponding

remote branch that ‘git pull‘ uses to update the current branch.

See ‘git help config‘ and search for ‘push.default‘ for further information.

(the ‘simple‘ mode was introduced in Git 1.7.11. Use the similar mode

‘current‘ instead of ‘simple‘ if you sometimes use older versions of Git)

Username for ‘https://github.com‘: wusang

Password for ‘https://[email protected]‘:

Counting objects: 24, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (21/21), done.

Writing objects: 100% (23/23), 8.51 KiB | 0 bytes/s, done.

Total 23 (delta 3), reused 0 (delta 0)

To https://github.com/wusang/lanou02.git

c054ac6..41b1085  master -> master

wuxiaoyuan:lanou02 lan$ git status

On branch master

Your branch is up-to-date with ‘origin/master‘.

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git checkout -- <file>..." to discard changes in working directory)

modified:   lanou02/lanou02/ViewController.h

modified:   lanou02/lanou02/ViewController.m

no changes added to commit (use "git add" and/or "git commit -a")

wuxiaoyuan:lanou02 lan$ git add .

wuxiaoyuan:lanou02 lan$ git commit -am "从暂存库添加到本地仓库,添加了1111"

[master f27a890] 从暂存库添加到本地仓库,添加了1111

2 files changed, 4 insertions(+)

wuxiaoyuan:lanou02 lan$ git push

warning: push.default is unset; its implicit value is changing in

Git 2.0 from ‘matching‘ to ‘simple‘. To squelch this message

and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to ‘matching‘, git will push local branches

to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative ‘simple‘

behavior, which only pushes the current branch to the corresponding

remote branch that ‘git pull‘ uses to update the current branch.

See ‘git help config‘ and search for ‘push.default‘ for further information.

(the ‘simple‘ mode was introduced in Git 1.7.11. Use the similar mode

‘current‘ instead of ‘simple‘ if you sometimes use older versions of Git)

Counting objects: 11, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (6/6), done.

Writing objects: 100% (6/6), 607 bytes | 0 bytes/s, done.

Total 6 (delta 4), reused 0 (delta 0)

To https://github.com/wusang/lanou02.git

41b1085..f27a890  master -> master

wuxiaoyuan:lanou02 lan$

与git相配合

简单步骤:

》1.注册一个github账号

》2.配置SSH Keys, 只要配置了SSH Keys就可以和github无缝衔接

》点击昵称来到个人主页

》 点击主页中的设置(setting)

》 点击SSH Keys

》点击 generating SSH keys

》1.检查本地的ssh keys

在“用户目录”下 ls -al ~/.ssh

2.如果文件夹不存在需要手动创建一个

mkdir .ssh

3.根据github的提示2生成ssh keys

在.ssh目录下执行 ssh-keygen -t rsa -C "[email protected]”

输入完成之后连续按下回车, 知道出现牛逼的图形位置

4.生成完公钥和私钥之后输入

ls -la查看是否生成成功   id_rsa(私钥) id_rsa.pub(公钥)

5.根据提示3获得公钥

pbcopy < ~/.ssh/id_rsa.pub

6.点击 setting —》 ssh key —>add ssh key

将刚才获取到得公钥添加进去

7.更具github第4步提示, 验证公钥

验证成功网页上的灰色圆点会变成绿色

8.拷贝到公钥之后打开github主页

》点击仓库(Repositories)

》再点击new来到github创建仓库界面

9.通过github提供的地址下载一个空得仓库到本地

》创建一个新的项目到本地仓库文件夹中

》利用Xcode提交代码到github

》注意: 要求输入用户名密码时候, 输入的是github上显示的昵称而不是登录账号

详细步骤:

在桌面建立两个空文件”张三””李四"(模拟多人开发)

1.进入https://github.com (先要注册githup个人账号)

2.

点击进入

进入后界面有step1~step5 参照操作

终端命令行:

1.step1 用来确认状态: ls -al ~/.ssh(输出结果表明  张三文件夹没有.ssh文件)

建立.ssh文件:

mkdir .ssh

cd 路径

2.生成公钥

step 2: ssh-keygen -t rsa -b 4096 -C "[email protected]"

3.Step 3: Add your key to the ssh-agent

Step 4: Add your SSH key to your account

Step 5: Test the connection

多人开发情况:

另一个人”李四”现在桌面的文件夹是空的

终端:

找到李四文件夹路径:cd 拖过来的文件夹路径

clone 仓库网址:git clone URL网址

打开李四原来的空文件夹,发现已经克隆下来了工程

拉取其他人已经提交的代码

终端:

找到文件夹下的工程路径: cd /Users/lan/Desktop/李四/lanou02

拉取工程: git pull

打开李四文件夹下的工程,发现已经同步到张三修改后的代码

时间: 2024-07-31 13:56:13

GitHub 建立远程仓库的相关文章

windows下使用git和github建立远程仓库

从昨天开始就在看git的使用,因为在Windows下很多命令行操作都比较坑爹,但是今天再走了无数弯路之后终于完成了git本地仓库和远程仓库的关联,记录如下, 首先感谢廖大神的博客的http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000, 同时感谢这位朋友http://blog.baibaobing.com/other/99.html的记录帮我解决了问题. 正文开始, 我会结合一个实例来介

Git学习--使用git base命令行在github建立远程仓库

今天终于学习了一下git,虽然还没完全了解git和svn的不同之处,但也算掌握了git的一些基本操作了,看了好几个教程,终于会了!!! 以前以为git就是github,真是too naive too simple.... 步入正题: 第一步,在github新建项目,选择new Repository  第二步,配置git,将代码上传到本地仓库. 首先,配置用户名和Email git config --global user.name "Your Real Name" git config

git使用(2) --在github上建立远程仓库

使用github作为远程仓库github官网:https://github.com/ 1.创建ssh key 如果没有.ssh 目录,或者.ssh 目录下没有id_rsa和id_rsa.pub这两个文件: ssh-keygen -t rsa -C "[email protected]" 复制 id_rsa.pub 到ssh key中.新建一个key即可. 2.添加远程库 登陆GitHub,然后,在右上角找到“Create a new repo”按钮,创建一个新的仓库. 3.本地上传(首

建立远程仓库,克隆远程仓库

建立远程仓库 首先到 http://github.com 注册一个账号 登录后,创建 repository (远程的服务端仓库) 客户端上创建密钥对,将公钥传给服务端 在客户端上创建仓库,并初始化 在客户端上建立测试文件提交给服务端,并推送给服务端 在服务端查看 再次创建一个文件提交推送到服务端 在服务端查看 在服务端创建新的仓库apeng 将客户端的公钥传递给服务端 在客户端上创建仓库,并初始化,建立测试文件提交给服务端,并推送给服务端 mkdir /apeng cd /apeng echo

Android基础入门教程——1.5.2 Git之使用GitHub搭建远程仓库

Android基础入门教程--1.5.2 Git之使用GitHub搭建远程仓库 标签(空格分隔): Android基础入门教程 本节引言: 在上一节中,我们学习了如何使用Git,构建我们的本地仓库,轻松的实现了版本控制以及代码还原,修改日志查看等:读者肯定不满足与本地是吧,假如是多个人一起来开发一个程序呢?我们需要一个作为服务器的远程仓库!当然搭建一个服务器是需要成本的,为什么不把项目托管到Github上呢?作为开源代码库以及版本控制系统,Github拥有140多万开发者用户.随着越来越多的应用

使用github作为远程仓库的常见git操作

[git上传本地代码到github新建仓库]一.建立git本地仓库 1.在本地目标文件夹(Code)中执行命令: git init //初始化本地仓库二.将上传到github的项目文件添加到本地仓库中: 1.将本地需要上传的工程代码复制到Code中: git status //查看本地仓库文件状态 2.将需要上传的文件纳入版本控制 git add XX //XX为目标文件(夹)名,此时执行git status命令,目标文件变为绿色 3.将需要上传的文件提交到本地仓库 git commit -m

github创建远程仓库和git常用命令

git创建远程仓库 首先到github页面上创建仓库(repository)如下: 然后初始化文件夹为仓库,并提交到远程仓库,如下: [[email protected] aa]# git init Initialized empty Git repository in /data/mydata/aa/.git/ [[email protected] aa]# git add . [[email protected] aa]# git commit -m "first commit"

github 删除远程仓库项目中的任意文件夹

今天上传代码把不需要的push上去了.结果想删除那个不想要的怎么弄都不行.网上大部分都是把那个项目整个暴力删除.那可不行啊那么多都删除.下次上传不是要命啊! 试啊试终于解决了.顺便记录一下也帮助下需要的朋友. 看下图1: 比如我想删除webqq这个文件夹 github命令: $git rm  -r  --cached  加文件名 如图2: 敲回车键 然后输入 $git commit -m 加文件名 如图3: 敲回车键 然后push提交信息 $git push origin master 如图4:

第一次使用github、git工具,本地仓库、远程仓库使用

一次使用git,记录下使用过程...可能还有很多东西可能还没理解,后期理解了再写吧 git是什么.,百度的回答: 一:Git是什么? Git是目前世界上最先进的分布式版本控制系统. 使用过程一直在百度,,,下面是百度时,觉得比较有参考价值的文章 参考的链接,搞不定的时候去看看,谢谢前人大佬些的辛勤奉献: https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242