关于如何使用 GIT 正确比较暂存区内容与上次提交的一些疑问?
Some doubts about how correctly compare the staging area content with the last commit using GIT?
我是 GIT 的新手,我对 git diff 的正确使用有以下疑问 -- staged 应该将 暂存区 内容与上次提交进行比较。
所以我得到了这个输出:
$ git diff --staged
diff --git a/game.js b/game.js
index 49bf5ea..0783175 100644
--- a/game.js
+++ b/game.js
@@ -421,6 +421,7 @@ Ship = function () {
}
if (KEY_STATUS.space) {
if (this.delayBeforeBullet <= 0) {
+ this.delayBeforeBullet = 10;
// added to fix the bug !!!
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
SFX.laser();
@@ -539,6 +540,7 @@ BigAlien = function () {
this.delayBeforeBullet -= delta;
if (this.delayBeforeBullet <= 0) {
+ //if (this.delayBeforeBullet = 10) {
this.delayBeforeBullet = 22;
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids ((3884eab
...))
那么这个输出到底意味着什么?我认为这意味着,在 暂存区 我添加了这两行:
1)
+ this.delayBeforeBullet = 10; // added to fix the bug !!!
2)
+ //if (this.delayBeforeBullet = 10) {
我在上次提交中没有。
我的推理是否正确?
是的,但更准确的说法是,在暂存区中,您有一个包含这两行额外行的文件版本。
暂存区包含完整的文件,而不仅仅是与其他文件的差异。它还具有其他文件的完整副本;它们与 HEAD
提交中的文件版本相同,因此 git diff
不显示它们。
我是 GIT 的新手,我对 git diff 的正确使用有以下疑问 -- staged 应该将 暂存区 内容与上次提交进行比较。
所以我得到了这个输出:
$ git diff --staged
diff --git a/game.js b/game.js
index 49bf5ea..0783175 100644
--- a/game.js
+++ b/game.js
@@ -421,6 +421,7 @@ Ship = function () {
}
if (KEY_STATUS.space) {
if (this.delayBeforeBullet <= 0) {
+ this.delayBeforeBullet = 10;
// added to fix the bug !!!
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
SFX.laser();
@@ -539,6 +540,7 @@ BigAlien = function () {
this.delayBeforeBullet -= delta;
if (this.delayBeforeBullet <= 0) {
+ //if (this.delayBeforeBullet = 10) {
this.delayBeforeBullet = 22;
for (var i = 0; i < this.bullets.length; i++) {
if (!this.bullets[i].visible) {
Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/asteroids ((3884eab
...))
那么这个输出到底意味着什么?我认为这意味着,在 暂存区 我添加了这两行:
1)
+ this.delayBeforeBullet = 10; // added to fix the bug !!!
2)
+ //if (this.delayBeforeBullet = 10) {
我在上次提交中没有。
我的推理是否正确?
是的,但更准确的说法是,在暂存区中,您有一个包含这两行额外行的文件版本。
暂存区包含完整的文件,而不仅仅是与其他文件的差异。它还具有其他文件的完整副本;它们与 HEAD
提交中的文件版本相同,因此 git diff
不显示它们。