Now only I got to know that there are 2 "types" of the local repository in the Git world. The first one is used to compare it against the local repository, where the command for this is
git diff ; the second one is used to compare it against the remote repository, where the command for this is git diff --cached. One thing that really confuses me is there are 2 stages in local repository, one is called Changes not staged or commit, whereas the other one is called Changes to be committed.
Confuse huh? Every time when I have done something, and I need to know the changes happen to my local PC, I'll use the command
git status. The following will shows up:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: backupUtilUnitTest/backupUtilUnitTest.pro
modified: core/BackupHeader.h
modified: core/FileBot.cpp
modified: core/FileBot.h
modified: core/FileHelper.cpp
modified: core/FileHelper.h
modified: core/FileNode.h
new file: unittest/FileBotUnderTest.cpp
new file: unittest/FileBotUnderTest.h
modified: unittest/testloadfiles.cpp
new file: unittest/testsearch.cpp
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: backupUtilUnitTest/backupUtilUnitTest.pro.user
modified: unittest/testlab.cpp
Untracked files:
(use "git add <file>..." to include in what will be committed)
backupUtil.zip
backupUtilUnitTest/backupUtilUnitTest.pro.user.RX2720
Take closer attention here, when I have changes to my work in my local computer, only
git diff is useful here. If I use the command
git diff --cached will show nothing. This experiment shows that I am comparing the changes with the work locate in the local PC with the local repository locate at the level named
Changes not staged for commit. When I issue the command
git add , the file will be moved from the level of
Changes not staged for commit to a new level named
Changes to be committed. Nothing will show up if the command
git diff is used. At this stage,
git diff --cached can only be used, and this will only compare the file at the level named
Changes to be committed to the remote repository, not the one in local PC. If anything has been changed to the file, the changes will not reflect with this command. But if I use the command
git diff , this will show on the changes I have made to the file in local PC.
No comments:
Post a Comment