diff of git command

The git command is used to view the difference between the files in the two states, adding different parameters, you can view different states, such as the workspace and the staging area, the workspace and the local repository, the staging area and the local repository, different branches inferior. Let's take a look at the specific commands.

1. Workspace VS Staging Area

$ git diff <filename>

Explanation: View the difference between the file in the work area and the staging area. If the file has not been added to the temporary storage area, check the difference before and after the modification of the file itself. You can also see the difference with another branch,

$ git diff <branch> <filename>

2. Staging area VS local repository

$ git diff --cached <filename>

3. Workspace VS local repository

$ git diff HEAD <filename> If HEAD points to the master branch, HEAD can also be changed to master

4. Workspace VS specifies commit-id

$ git diff commit-id <filename>

5. Specify commit-id VS specify commit-id

$git diff <commit-id> <commit-id>

6. Staging area VS specified commit-id

$git diff --cached <commit-id> <filename>

Replenish:

The above command can not specify <filename>, then all sorting operations will be performed.

HEAD last commit

HEAD^Last commit

100 commits on HEAD~100


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325938907&siteId=291194637