GitHub最基本使用总结

GitHub最基本使用入门

入门必看博客:https://mp.weixin.qq.com/s/LbzSwl4dYwrSPze0w10l8w

一、Git Linux安装

Git Linux安装教程:https://book.git-scm.com/download/linux

二、Git window安装

1.     下载地址

a)      https://gitforwindows.org/            

b)     https://book.git-scm.com/download/win

2.     配置SSH Key

在本地运行软件产生SSHKey:$ssh-keygen -t rsa -C “[email protected]”,邮件地址为自己的联系邮件,一直回车就好。

登陆网址(https://github.com/settings/keys)点击账号设置中的”SSH and GPG keys”,点击”newSSH Key”,在Title中随便输入,在Key中输入C:\Users\Administrator\.ssh\id_rsa.pub文件中保持的key。

3.     验证SSH Key

验证SSHKey是否设置成功输入:$ ssh [email protected],如果提示continue则说明连接成功。

4.     配置username和email

$ git config --global user.name "muphy1112"

$ git config --global user.email [email protected]

三、Git使用

1.     使用教程

https://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E6%89%93%E6%A0%87%E7%AD%BE

2.     添加远程地址

$ git remote add muphy [email protected]:muphy1112/muphy.git

3.     查看分支

$ git branch

4.     添加文件

$ git add .

5.     提交文件

$ git commit –m “注释”

6.     推送文件

$ git push muphy muphyblog:muphyblog 或$ git push [email protected]:muphy1112/muphy.git

四、错误处理

出现下列错误是因为缺少README.md文件,运行git pull --rebase muphy muphyblog即可。

$ gitpush --set-upstream [email protected]:muphy1112/muphy.git muphyblog

Togithub.com:muphy1112/muphy.git

! [rejected]        muphyblog -> muphyblog (fetch first)

error:failed to push some refs to '[email protected]:muphy1112/muphy.git'

hint:Updates were rejected because the remote contains work that you do

hint:not have locally. This is usually caused by another repository pushing

hint:to the same ref. You may want to first integrate the remote changes

hint:(e.g., 'git pull ...') before pushing again.

hint:See the 'Note about fast-forwards' in 'git push --help' for details.

五、参数说明

a)      [email protected] 为SSH协议

b)     muphy为存储仓库名

c)      muphy1112为GitHub账户名

d)     [email protected]为自己注册的GitHub邮箱

e)      [email protected]:muphy1112/muphy.git为存储仓库路径

f)      muphyblog为muphy仓库下的分支

猜你喜欢

转载自www.cnblogs.com/muphy/p/10781453.html