Git 从零到能推送到GitHub远端库

目录

1.注册github帐户。
2.下载git命令工具。
3.建立本地git仓库
4.设置帐户的SSH 密钥。
5.链接远程github仓库

建立github帐户

注册Git地址:https://github.com
下载git工具:https://git-scm.com/downloadsgit

clipboard.png

建立gitgub仓库

登陆github后,在右上角,如图所示。
建立github仓库时输入名字便可,其余尽可能别动。推荐使用谷歌浏览器,能够自动翻译为中文。
clipboard.pnggithub

clipboard.png

谷歌浏览器
clipboard.pngshell

建立本地Git仓库

在桌面右键打开Git Bath here 命令行工具vim

配置:浏览器

git config --global user.name "Your Name"   配置用户名
git config --global user.email "email@example.com"  配置你的邮箱
git config --global push.default matching
git config --global core.quotepath false
git config --global core.editor "vim"

建立一个目录( 不要包含中文 ) mkdir 目录名
进入这个目录(文件夹):cd 目录名
将这个目录变成git能够管理的仓库 git init
这个目录(文件夹)就是本地仓库了bash

链接远程仓库

设置SSH key:https://github.com/settings/keysssh

生成SSH key(密钥):在bash命令行工具组输入  rm -rf ~/.ssh/*
 ssh-keygen -t rsa -b 4096 -C "你的邮箱"

clipboard.png

回车三次。
 运行: cat ~/.ssh/id_rsa.pub  会获得一串东西

clipboard.png

复制粘贴到

clipboard.png

在新建的目录下运行:ssh -T git@github.com

若是看到 Hi FrankFang! You've successfully authenticated, but GitHub does not provide shell access.表明咱们的SSH key 已经设置成功
首先咱们在目录下作一些修改:
如新建一个文件ss.txt ,
在bash中:git status -sb 查看 获得:ide

$ git status -sb
## No commits yet on master
?? ss.txt

将修改提交到暂存库中,能够用git add 命令工具

Git add 文件路径 或 Git add .

clipboard.png

将暂存库内的修改提交到本地fetch

Git commit -m”说明”

clipboard.png

链接远程库

clipboard.png
输入:

git remote add origin git@github.com:你的用户名/git仓库名.git

clipboard.png

能够运行git remote -v 查看本地仓库权限

clipboard.png

若是如上图显示有fetch和push权限,说明已经进行了链接
接下来,将本地修改推送到远端仓库:

git push -u origin master

如今已经推送到远端,能够去github上查看一下

clipboard.png


若有疑问可在下方留言,或参考其余文档,如有错误,也欢迎在下方留言。

相关文章
相关标签/搜索