1.git介绍
1.版本控制器
为了能够更⽅便我们管理这些不同版本的⽂件,便有了版本控制器。所谓的版本控制器,就是能让你了解到⼀个⽂件的历史,以及它的发展过程的系统。通俗的讲就是⼀个可以记录⼯程的每⼀次改动和版本迭代的⼀个管理系统,同时也⽅便多⼈协同作业。⽬前最主流的版本控制器就是 Git
。Git可以控制电脑上所有格式的⽂件,例如doc、excel、dwg、dgn、rvt等等 。对于我们开发⼈员来说,Git最重要的就是可以帮助我们管理软件开发项⽬中的源代码⽂件!
2.git简史
同⽣活中的许多伟⼤事物⼀样,Git诞⽣于⼀个极富纷争⼤举创新的年代。
Linux内核开源项⽬有着为数众多的参与者。绝⼤多数的Linux内核维护⼯作都花在了提交补丁和保存归档的繁琐事务上(1991−2002年间)。到2002年,整个项⽬组开始启⽤⼀个专有的分布式版本控制系统BitKeeper来管理和维护代码。到了2005年,开发BitKeeper的商业公司同Linux内核开源社区的合作关系结束,他们收回了Linux内核社区免费使⽤BitKeeper的权⼒。这就迫使Linux开源社区(特别是Linux的缔造者LinusTorvalds)基于使⽤BitKeeper时的经验教训,开发出⾃⼰的版本系统。
⾃诞⽣于2005年以来,Git⽇臻成熟完善,在⾼度易⽤的同时,仍然保留着初期设定的⽬标。它的速度⻜快,极其适合管理⼤项⽬,有着令⼈难以置信的⾮线性分⽀管理系统。
2.linux下拉取gitee远端仓库(git三板斧)
1.新建一个仓库

仓库明细如下:
可以看到有两个初始的.md文件(注意)
2.获取gitee仓库地址
这个就是我们需要的仓库地址
3.拉取gitee远端仓库
- 使用
git clone +仓库网址
就能把仓库内容拉取出来 - 可见两个md文件与仓库中的一致
3.在拉下来的仓库里新增内容并提交到远程仓库

这里使用了其他大佬的图。

这里我们在克隆的目录下新建一个code.c我们可以使用vim在文件里写入一些代码。
1.git add code.c

请问这里code.c有被直接提交到本地仓库吗?
NO!
当前code.c只是被存在了暂存区 (方便收回,避免提交错误的代码到远程仓库里)

2.git status(查看当前情况)

那么,我们有办法传到本地仓库吗?
有的,兄弟有的:
3.git commit -m "新增一个文件"(在git add的基础上)

这个时候会报错,因为我们是第一次使用git,需要给 邮箱和名字

这里大佬们可以填自己的

再次使用就成功啦。
4.git log (相当于日志)

可以用来查看日志,检查错误
5.git push

第一次使用需要将红框中的内容任选其一输入到终端
然后再输入git push

输入密码和账户即可

远程仓库也完成了传输啦。
4.git指令扩充
- 删除仓库中的文件 ------
git rm 文件名
- 查看本地和远端之间同步的状态 ------
git status
- 删除本地仓库 ------
rm .git

code.c文件已经被删除

使用git status也显示code.c被删除
接下来我们把下载的本地仓库也删除:

这里再次使用git status 发现没法查看,因为.git已经被删除。

- 我们可以看到有个.gitignore文件,这个文件储存着
所有会被忽视的文件后缀
,即如果在linux/windows下传了上述后缀的文件,仓库里是不会显示这些文件的