Git的导入¶
什么是版本管理¶
版本管理就是管理更新的历史记录。它为我们提供了一些在软件开发过程中必不可少的功能,例如记录一款软件添加或更改源代码的过程,回滚到特定阶段,恢复误删除的文件等。
集中型与分散型¶
集中型¶
以Subversion为代表的集中型
分散型¶
Git为代表的分散型
所有仓库之间都可以进行push和pull。即便不通过GitHub,开发者A也可以直接向开发者B的仓库进行push或pull。因此在使用前如果不事先制定规范,初学者往往会搞不清最新的源代码保存在哪里,导致开发失去控制。
初始设置¶
●设置姓名和邮箱地址首先来设置使用Git时的姓名和邮箱地址。名字请用英文输入。
$ git config --global user.name "hujianli"
$ git config --global user.email "hujiainli@126.com"
clone已有仓库¶
$ git clone git@github.com:hujianli94/jenkins001.git
Cloning into 'jenkins001'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 29 (delta 5), reused 27 (delta 3), pack-reused 0
Receiving objects: 100% (29/29), 2.42 KiB | 130.00 KiB/s, done.
Resolving deltas: 100% (5/5), done.
# 编写代码
$ cat hello_world.php
<? php
echo "hello world"
?>
# 查看状态
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello_world.php
# 提交
//git add命令将文件加入暂存区
$ git add hello_world.php
//git commit命令提交
$ git commit -m "Add hello world php file"
# git log命令查看提交日志。
$ git log
commit ffad5f8c525e690dfd58c772f6a746f5e532587a (HEAD -> master)
Author: hujianli <hujiainli@126.com>
Date: Thu Nov 19 21:13:43 2020 +0800
Add hello world php file
# 进行push
$ git push