分布式版本控制系统:Git学习笔记

概述

身为DBA的我前夕确实对于代码比较陌生啊,Git也是很少听过。不过随着工作的深入,发现这是必不可少的一项技能啊,就简单记一下我的学习过程吧
顺便提下我的Githup:https://github.com/Stephev
哈哈,虽然我只会写一点点点点的Python,这样显得专业

Git是什么

Git是目前世界上最先进的分布式版本控制系统
2008年,GitHub网站上线了,它为开源项目免费提供Git存储,无数开源项目开始迁移至GitHub,包括jQuery,PHP,Ruby等等。

Git的安装

Windows用户可在https://git-scm.com/downloads 下载好应用并安装
安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!

安装完成后,还需要最后一步设置,在命令行输入:设置自己的用户名和邮箱

$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"

创建版本库

在系统中找一个适合的地方,创建

$ mkdir learngit
$ cd learngit/
$ pwd
/d/Git_home/learngit

通过git init命令把这个目录变成Git可以管理的仓库:

$ git init
Initialized empty Git repository in D:/Git_home/learngit/.git/

编写文件上传

用notepad随便写点内容readme.txt,放在D:/Git_home/learngit/中
再执行

$ git add readme.txt
warning: LF will be replaced by CRLF in readme.txt.
The file will have its original line endings in your working directory.

$ git commit -m "wrote a readme file"
[master (root-commit) 6c88bdf] wrote a readme file
 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt

初始化一个Git仓库,使用git init命令。

添加文件到Git仓库,分两步:

使用命令git add ,注意,可反复多次使用,添加多个文件;
使用命令git commit -m ,完成。

使用GitHub

我们一直用GitHub作为免费的远程仓库,如果是个人的开源项目,放到GitHub上是完全没有问题的。其实GitHub还是一个开源协作社区,通过GitHub,既可以让别人参与你的开源项目,也可以参与别人的开源项目。

在GitHub上,可以任意Fork开源仓库;
自己拥有Fork后的仓库的读写权限;
可以推送pull request给官方仓库来贡献代码

  • 举例从GitHub上面讲antdb的源码下载下来
    先去找到项目库,找到下载链接

  • 使用Gitclone 将该链接下载下来
Administrator@SC-201801151233 MINGW64 /d/Git_home/learngit (master)
$ git clone https://github.com/ADBSQL/AntDB.git
Cloning into 'AntDB'...
remote: Counting objects: 516365, done.
remote: Compressing objects: 100% (2324/2324), done.
Receiving objects:   0% (3376/516365), 1.21 MiB | 2.00 KiB/s
  • 在库里就可以看到这么下载到的文件

猜你喜欢

转载自blog.csdn.net/qq_43303221/article/details/83583477