git 创建远程仓库

来源:互联网 发布:java生成随机数的方法 编辑:程序博客网 时间:2024/05/05 03:21
创建账号
https://github.com/
start a project >>>>>

https https://github.com/BillWing726/test.git
ssh git@github.com:BillWing726/test.git

创建连接认证
setting >>> ssh and GPG keys >>> New SSH key
  • Title 自定义,可以写日期,可以写 git 的名字
  • Key 去服务器上面生成公钥,拷贝到这里
# ssh-keygen
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
# cat /root/.ssh/id_rsa.pub
  • 将公钥拷贝到网站的 Key 对话框里面,此时如果成功会收到邮件。

建立连接
# cd /home/
# mkdir testgit 【本地的目录最好和远程的项目名称一致,方便管理】
# cd testgit
# git init # 初始化
# git remote add origin git@github.com:BillWing726/test.git# 建立远程连接,在远程建立一个新的仓库 testgit,名字尽量和本地一致。

推送文档
# vim 1.txt
# git add 1.txt
# git commit -m "add new txt"
# git push -u origin master # 推送到远程仓库,第一次提示是否建立连接。第一次完成之后,后面的推送,直接 git push 即可。