Git: 版本控制(3)
2019-03-21 本文已影响0人
柏龙
git diff 对比区别
- 直接输入
git diff后面不跟某个文件,即显示出所有文件的区别 -
git diff index.html表示单独查看index.html文件的区别,-表示上个版本的修改,+表示当前修改后的
diff --git a/index.html b/index.html
index aa8038f..6acd0f2 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="en">
+<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
-
git add index.html把index.html文件添加到暂存区 -
git status显示当前要提交的修改
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: index.html
-
git diff查看区别,现在没有新的修改显示,因为我们把index.html文件添加到了暂存区,它会跟工作目录里的文件进行比较 - 此时修改一下
index.html保存 -
git status查看修改后文件的状态
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: index.html
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index.html
-
git diff index.html此时又会对比出上次修改的区别
diff --git a/index.html b/index.html
index 6acd0f2..239d8d4 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
+ <title>git diff</title>
</head>
<body>
-
git commit -m '修改index.html的title'提交当前修改,备注为修改index.html的title -
git push origin master完成本次提交,并提交到主分支