作者:嵌入式历练者
ID : Eterlove
记下相关笔记,记录我的学习生活!站在巨人的肩上Standing on Shoulders of Giants!
该文章为原创,转载请注明出处和作者:https://blog.csdn.net/Eterlove/article/details/120782696
目录
1.创建一个简单的仓库
2.安装git最新版2.33.1
Git 是一个开源的分布式版本控制软件,用以有效、高速的处理从很小到非常大的项目版本管理。 Git 最初是由Linus Torvalds设计开发的,用于管理Linux内核开发。Git 是根据GNU通用公共许可证版本2的条款分发的自由/免费软件,而GitHub是一个基于Git的远程文件托管平台,超5千万开发者正在使用。GitHub中文社区是一个致力于分享和传播GitHub上优质开源项目的中文社区平台(互联网搜索得) https://www.githubs.cn/
这是GitHub的官方网站 https://github.com/
注册成功后,该如何创建一个仓库(或者说存储库)呢?点击 + ,在点击new repository(repository代表仓库的意思)
按如下解释创建一个新的仓库。
去官网下载https://git-scm.com/,根据自己系统选择,本篇在 Windows 上安装 。
自定义选择要放软件的盘,最好不要安在C盘
Additional icons在询问时是否创建桌面快捷图标
其它的,除了特别的需要,跟着图片走就是了
最后默认点install完成安装,右键桌面发现:git的两种打开方式,我们常用命令行方式
检查本机公钥输入cd ~/.ssh ,提示No such file or directory 说明你是第一次使用git
$输入 ssh-keygen -t rsa -C "[email protected]",引号中是自己在github上注册的邮箱
连续按三次回车,到如下图所示(rsa -C之间有空格,keygen -t rsa之间也有空格)
细节问题参考博客:Git生成公钥 bash:ssh-keygen command not found_夜雨灬闻铃的博客-CSDN博客
打开自己的github,按如下图找到SSH keys
需要注意的是,直接Ctrl c 复制 .ssh的文件会破坏格式,打开 git bash,输入命令
$ clip<~/.ssh/id_rsa.pub然后粘贴到github
输入下面命令验证是否成功
$ ssh -T [email protected]
出现以下信息,输入yes,出现 You've successfully authenticated, but GitHub does not provide
shell access.即表示成功
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (RSA) to the list of known hosts.
Hi Eterlove! You've successfully authenticated, but GitHub does not provide
shell access.
配置相关信息,为后面上传文件做准备,以后就不需要配置了,如下图
$ git config --global user.name"账号名称"
$ git config --global user.name"Eterlove"
账户名称,也就是用户名与github上保持一致即可
$ git config --global user.email"github注册的邮箱"
$ git config --global user.email"[email protected]"、
这里必须是github注册的邮箱, " "不能扔掉
我电脑的重要文件准备放在E盘,所以cd命令进入E盘 cd /E (在window下盘符大写E)
使用clone命令下载仓库,输入命令$ git clone 地址,这个地址就是你的仓库(或者说存储库)的地址,如何知道仓库的地址呢?如图repository就是仓库的意思。book是我刚刚创建的仓库,点开它,找到地址
小脑袋瓜昏头了@DESKTOP-D15KFDC MINGW64 /E
$ git clone https://github.com/Eterlove/book.git
Cloning into 'book'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
接下来,我们去看看E盘,已经有了book仓库
接下来,我们就可以使用git add(表示添加到本地库),git push origin master(推送到远程库的master分支)等命令上传文件到仓库哦!
若出现以下的问题error: failed to push some refs to 'https://github.com/Eterlove/book.git'
参考博客解决办法:git错误 error: failed to push some refs to 'https://github.com/..._Bluetata's Tech.Blog-CSDN博客
参考更多Git命令chttps://www.liaoxuefeng.com/wiki/896043488029600