博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
把本地仓库工程上传到github上和从gitbu同步工程到本地
阅读量:6925 次
发布时间:2019-06-27

本文共 5274 字,大约阅读时间需要 17 分钟。

1、在本地产生秘钥和公钥

[root@jacky git_project]# ssh-keygen -t rsa -C "jacky-lulu@1073740572@qq.com"Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa      #在这里输入rsa秘钥所在的目录Enter passphrase (empty for no passphrase):                                     #输入jacky-lulu账号的密码Enter same passphrase again:                                                    #再次输入jacky-lulu账号的密码Your identification has been saved in /root/.ssh/id_rsa.                        #保存秘钥的文件(id_rsa)Your public key has been saved in /root/.ssh/id_rsa.pub.                        #保存公钥的文件(id_rsa.pub)

2、查看公钥

[root@jacky /]# cd /root[root@jacky ~]# ls -al总用量 156dr-xr-x---.  5 root root  4096 12月 31 18:26 .dr-xr-xr-x. 25 root root  4096 12月 31 13:37 ..-rw-------.  1 root root  1595 10月  7 09:49 anaconda-ks.cfg-rw-------.  1 root root 16744 12月 30 21:33 .bash_history-rw-r--r--.  1 root root    18 5月  20 2009 .bash_logout-rw-r--r--.  1 root root   176 5月  20 2009 .bash_profile-rw-r--r--.  1 root root   176 9月  23 2004 .bashrc-rw-r--r--.  1 root root   100 9月  23 2004 .cshrcdrwx------.  2 root root  4096 10月  7 09:51 .gconfdrwx------.  2 root root  4096 10月  7 09:53 .gconfd-rw-r--r--.  1 root root    66 12月 31 17:16 .gitconfig-rw-r--r--.  1 root root 43838 10月  7 09:49 install.log-rw-r--r--.  1 root root 10033 10月  7 09:46 install.log.syslog-rw-------.  1 root root    35 12月 31 18:26 .lesshst-rw-------.  1 root root  3380 12月 11 21:20 .mysql_history-rw-------.  1 root root    78 11月 10 20:19 .mysql_secret-rw-r--r--.  1 root root   879 11月  5 18:14 .rediscli_historydrwx------.  2 root root  4096 12月 31 18:59 .ssh-rw-r--r--.  1 root root   129 12月  4 2004 .tcshrc-rw-------.  1 root root  5190 12月 31 18:18 .viminfo-rw-------.  1 root root    57 12月 10 21:54 .xauthAy9Cwu[root@jacky ~]# cd .ssh[root@jacky .ssh]# ls -l总用量 12-rw-------. 1 root root 1743 12月 31 18:59 id_rsa-rw-r--r--. 1 root root  405 12月 31 18:59 id_rsa.pub-rw-r--r--. 1 root root 1184 12月 29 17:10 known_hosts

[root@jacky .ssh]# cat id_rsa.pub

  ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyzSZ+5GNn98KxUkEthl4dg8knuTb8znI/oyZ6kzuObZ7AoOd2T/fJVirHE7FKq0nw5zwUF1xez0F8SEgMzQJuXECmEo86DWaYY+Qhh7KSdw30E8g   GVMcJvTbMBbQx/tmb9NrjT44STe+sg6HbW8keFxS8VnpJJww26RhGaZzQz30lA55mNF7H7ELfG9pyApNs9iFZFWGf7T/OWQtDQ5v0quNoW3xqBfn0eMHYe0ebZGnIfLumBE8DZAuxOqK6FHw== j a  cky@1073740572@qq.com
[root@jacky .ssh]# ssh -T git@github.com

3、在github自己账号上输入公钥

4、验证连接github的jacky-lulu账号的公钥是否可行

ssh -T git@github.comThe authenticity of host 'github.com (192.30.253.112)' 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)? yesWarning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.Enter passphrase for key '/root/.ssh/id_rsa': Hi jacky-lulu! You've successfully authenticated, but GitHub does not provide shell access.

5、进入的本地仓库的工程,建立与github的jacky-lulu的连接

[root@jacky home]# cd git_project[root@jacky git_project]# ls -l总用量 8-rw-r--r--. 1 root root 28 12月 31 18:32 1.java-rw-r--r--. 1 root root 80 12月 31 18:32 2.java[root@jacky git_project]# ls1.java  2.java[root@jacky git_project]# git remote add origin https://github.com/jacky-lulu/git_project.git[root@jacky git_project]# git remoteorigin[root@jacky git_project]# git remote -vorigin    https://github.com/jacky-lulu/git_project.git (fetch)       #从github下载工程的连接origin    https://github.com/jacky-lulu/git_project.git (push)        #往github上传工程的连接

6、首先在github上创建一个新工程,名称叫git_project(与本地工程名称同名)

7、往github上push工程git_project

[root@jacky git_project]# git push -u origin master      #表示把当前master分支push到github上(gnome-ssh-askpass:15702): Gtk-WARNING **: cannot open display: error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'Username for 'https://github.com': jacky-lulu               #输入账号名称(gnome-ssh-askpass:15708): Gtk-WARNING **: cannot open display: error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'Password for 'https://jacky-lulu@github.com':               #输入密码对象计数中: 26, 完成.压缩对象中: 100% (19/19), 完成.写入对象中: 100% (26/26), 2.02 KiB | 0 bytes/s, 完成.Total 26 (delta 2), reused 0 (delta 0)remote: Resolving deltas: 100% (2/2), done.To https://github.com/jacky-lulu/git_project.git * [new branch]      master -> master分支 master 设置为跟踪来自 origin 的远程分支 master。

8、故意在github上修改工程git_project工程的2.java文件在同步到本地

[root@jacky git_project]# git fetch origin    #把gitgub远端仓库同步到缓冲区remote: Counting objects: 3, done.remote: Compressing objects: 100% (3/3), done.remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0展开对象中: 100% (3/3), 完成.来自 https://github.com/jacky-lulu/git_project   c1f3cea..0c2df23  master     -> origin/master[root@jacky git_project]# ls1.java  2.java[root@jacky git_project]# cat 2.javamaster 2master 3master 4branch jacky1master jacky222branch jacky222222222[root@jacky git_project]# git merge origin/master    #把缓冲区的合并到本地库的master分支上更新 c1f3cea..0c2df23Fast-forward 2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)[root@jacky git_project]# cat 2.javamaster 2master 3master 4branch jacky1master jacky222branch jacky222222222远程仓库修改内容22222222222222222222222222222222222222222222    #同步成功

 

转载于:https://www.cnblogs.com/520playboy/p/6241534.html

你可能感兴趣的文章
Android 解决TextVIew载入自己定义字体慢的问题
查看>>
poj2406 Power Strings
查看>>
Lintcode---验证二叉查找树
查看>>
boost - 正则表达式xpressive
查看>>
java:Writer/Reader字符流操作
查看>>
如何判断一门技术的成熟度
查看>>
C语言学习笔记 (002) - C++中引用和指针的区别(转载)
查看>>
git常用命令转载
查看>>
powerdesigner设置主键为自增字段,设置非主键为唯一键并作为表的外键
查看>>
LeetCode 14: Longest Common Prefix
查看>>
架构高性能站点秘笈(六)——构建数据缓冲区
查看>>
hbase hmaster故障分析及解决方案:Timedout 300000ms waiting for namespace table to be assigned...
查看>>
测试图拍呢
查看>>
【Java学习笔记之十二】Java8增强的工具类:Arrays的用法整理总结
查看>>
Images.xcassets 的简单使用
查看>>
PHP控制连接打印机
查看>>
Tomcat中的backlog参数
查看>>
Ubuntu · Docker —— 从入门到实践
查看>>
浅析MySQL中的Index Condition Pushdown (ICP 索引条件下推)和Multi-Range Read(MRR 索引多范围查找)查询优化...
查看>>
ZIP排除指定目录进行压缩
查看>>