目录
本节内容
- 常?的传输协议:哑协议和智能协议
- 演示1:使用哑协议、智能协议方式将仓库备份到本地
- 演示2:本地工作空间频繁变动,此时如何将仓库备份到本地远程仓库
1、常?的传输协议
🍀 哑协议与智能协议
**直观区别:**哑协议传输进度不可?;智能协议传输可?。
**传输速度:**智能协议?哑协议传输速度快。
🍀 备份特点
2、演示
演示1:使用哑协议、智能协议方式将仓库备份到本地
💘 演示:使用哑协议、智能协议方式将仓库备份到本地-2022.4.7(测试成功) |
1?? 本地创建一个备份目录
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit
$ mkdir 666-bakup
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit
$ cd 666-bakup/
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup
2?? 接下来,我们将本地仓库git_learning 通过哑协议 方式进行备份
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/git_learning
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ cd ../666-bakup/
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ git clone --bare /c/Users/hg/Desktop/it/01-SuGit/git_learning/.git ya.git
Cloning into bare repository 'ya.git'...
done.
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
?? 注意:–bare 不带工作区的裸仓库
3?? 然后,我们将本地仓库git_learning 通过智能协议 方式进行备份
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ git clone --bare file:///c/Users/hg/Desktop/it/01-SuGit/git_learning/.git zhineng.git
Cloning into bare repository 'zhineng.git'...
remote: Counting objects: 30, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 30 (delta 7), reused 0 (delta 0)
Receiving objects: 100% (30/30), 22.35 KiB | 673.00 KiB/s, done.
Resolving deltas: 100% (7/7), done.
智能协议有进度条显示;并且,专家也说了,智能协议不仅仅对存储做了打包,也做了压缩;
测试结束。😘
演示2:本地工作空间频繁变动,此时如何将仓库备份到本地远程仓库
💘 演示:如何将本地仓库备份到远程仓库-2022.4.7(测试成功) | 演示2:本地工作空间频繁变动,此时如何将仓库备份到本地远程仓库
1?? 查看下当前仓库的远程分支有哪些?
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/git_learning
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ git remote -v
发现,当前git仓库并没有一个远程仓库,因此,我们这里给新建一个远程仓库:
先查看下前面使用智能协议备份过来的仓库:
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ ls -l
total 8
drwxr-xr-x 1 hg 197121 0 Apr 6 07:42 ya.git/
drwxr-xr-x 1 hg 197121 0 Apr 6 07:43 zhineng.git/
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup
$ cd zhineng.git/
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup/zhineng.git (BARE:temp)
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup/zhineng.git (BARE:temp)
新建一个远程仓库:
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ git remote add zhineng file:///c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git
我们看下当前仓库和远程仓库的分支情况:
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup/zhineng.git (BARE:temp)
$ git branch -av
master 7b84beb Add the first command with config
* temp 30c1501 Add test
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/git_learning
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ git branch -av
master 7b84beb Add the first command with config
* temp 30c1501 Add test
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (temp)
$ git checkout -b suling temp
Switched to a new branch 'suling'
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ git branch -av
master 7b84beb Add the first command with config
* suling 30c1501 Add test
temp 30c1501 Add test
2?? 将本地仓库备份到远程仓库
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ git remote -v
zhineng file:///c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git (fetch)
zhineng file:///c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git (push)
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ git push zhineng
fatal: The current branch suling has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream zhineng suling
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ git push --set-upstream zhineng suling
Total 0 (delta 0), reused 0 (delta 0)
To file:///c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git
* [new branch] suling -> suling
Branch 'suling' set up to track remote branch 'suling' from 'zhineng'.
3?? 验证
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup/zhineng.git (BARE:temp)
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/666-bakup/zhineng.git
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/666-bakup/zhineng.git (BARE:temp)
$ git branch -av
master 7b84beb Add the first command with config
suling 30c1501 Add test
* temp 30c1501 Add test
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ pwd
/c/Users/hg/Desktop/it/01-SuGit/git_learning
hg@LAPTOP-G8TUFE0T MINGW64 ~/Desktop/it/01-SuGit/git_learning (suling)
$ git branch -av
master 7b84beb Add the first command with config
* suling 30c1501 Add test
temp 30c1501 Add test
remotes/zhineng/suling 30c1501 Add test
实验结束。😘
关于我
我的博客主旨:我希望每一个人拿着我的博客都可以做出实验现象,先把实验做出来,然后再结合理论知识更深层次去理解技术点,这样学习起来才有乐趣和动力。并且,我的博客内容步骤是很完整的,也分享源码和实验用到的软件,希望能和大家一起共同进步!
各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人免费帮您解决问题:
-
个人微信二维码:x2675263825 (舍得), qq:2675263825。 -
个人微信公众号:云原生架构师实战 -
个人博客地址:www.onlyonexl.cn -
个人csdn https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421 -
个人已开源干货😘
名称 | 链接 |
---|
01 实战:打造一款王者云笔记:typora+坚果云+阿里云oss & 定制宇宙中最美的typora主题皮肤(永久开源) | https://www.jianguoyun.com/p/DXS6qiIQvPWVCRiS0qoE | 02 玩转vscode(永久开源) | https://www.jianguoyun.com/p/DZe8gmsQvPWVCRid0qoE | 03 陈果的幸福哲学课 | https://www.jianguoyun.com/p/Db0kM7gQvPWVCRj2q6YE |
最后
好了,关于如何将Git仓库备份到本地实验就到这里了,感谢大家阅读,最后贴上我女神的photo,祝大家生活快乐,每天都过的有意义哦,我们下期见!
|