git diff use

See what parts of a file that hasn't been staged have been updated

$ git diff

This command compares the difference between the working directory (Working tree) and the staging area snapshot (index), that is, the changes that have not been staged (git add) after modification. If you execute git add and then execute git diff, there will be no differences.

View the difference between the file that has been staged (git add) (staged) and the snapshot at the time of the last commit (HEAD)

$ git diff --cached(1.6之前版本)
$ git diff --staged(1.6之后版本)

Displays the content that will be submitted to HEAD (Repository) when committing.

Display the difference between the working version (Working tree) and HEAD

$ git diff HEAD 

Regardless of whether git add is executed or not, there will be differences, but there will be no differences after git commit is executed.

Show differences between two branches

$ git diff branch1 branch2 //显示两个分支的不同
$ git diff branch1..branch2 //两个点
$ git diff master origin/master //显示本地分支和远程分支的不同

There is no relationship between branch1 and branch2, this command is to display the difference between branch2 and branch1

Outputs the changes on the master branch since develop and master were developed respectively.

$ git diff develop...master //三个点

If the master makes changes and commits after the develop and master are separated, executing the above command will display the changes on the master after development respectively, only the changes made on the master, not the difference between the develop and the master.

Guess you like

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