1.git diff作用
相信对git有一定了解的人都知道git status这个命令的作用,这个命令的作用是查看文件的状态,比如哪些文件还没被追踪,哪些文件还没有添加到暂存区,哪些文件被添加到了暂存区但还没被提交。总之就是可以让我们很直观地了解到文件大体上的一个状态。
D:\specialty_shop>git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
no changes added to commit (use "git add" and/or "git commit -a")
而git diff命令可以帮助我们更加仔细地了解文件具体发生变化的内容。
2.怎么去看git diff之后的内容
严格来说,git diff 命令比较的场景是当前工作目录和暂存区。也就是未添加暂存和已添加暂存的文件内容有什么变化。
D:\specialty_shop>git diff
diff --git a/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html b/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManag
ement.html
index 758c991..3d5719a 100644
--- a/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
+++ b/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
@@ -30,7 +30,9 @@
function deleteOrderByOrderNumber(obj) {
+ alert("lalala");
var orderNumber =$(obj).attr("name");
+
$.ajax({
type:"GET",
url:"http://localhost:18086/skip/accesstoken",
@@ -80,6 +82,10 @@
}
});
+ $("#del").click(function () {
+ alert("<E5><A5><BD><E7><9A><84>");
diff --git
a/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
b/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManag
ement.html
这一句的意思就是,比较a版本(改动前)的OrderManagement.html 和b版本(改动后)的OrderManagement.html,
index 758c991..3d5719a 100644
这句表示两个版本的git哈希值(index区域的6f8a38c对象,与工作目录区域的449b072对象进行比较)。
--- a/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
+++ b/specialty-parent/specialty-web/specialty-web-static-page/src/main/resources/static/shop/html/OrderManagement.html
“- - -”表示变动前的版本,“+++”表示改动后的版本。
@@ -30,7 +30,9 @@
-30,7 表示从a版本的文件的第30行开始,连续显示7行。
+30,9 表示从b版本的文件的第20行开始,连续显示9行。
function deleteOrderByOrderNumber(obj) {
+ alert("lalala");
var orderNumber =$(obj).attr("name");
+
$.ajax({
type:"GET",
url:"http://localhost:18086/skip/accesstoken",
这段显示的是变动的内容,在最前面的是标志位,在代码前的 “+”表示这行代码是b版本文件新增的。同理,若是显示“-”则表示是a版本文件删除的。若是没有则说明没有变化。
3.git diff --staged
前面的git diff比较的场景是工作目录和暂存区。而git diff --staged可以比较暂存区和最近一次提交的文件。