[ACCEPTED]-Comparing changes in commits to the current file by Git-git
Accepted answer
Here is my cheat-sheet:
# uncommited file to HEAD
git diff <path>
# uncommited file to before last commit
git diff HEAD^ -- <path>
#last commit to before last commit
git diff HEAD^ HEAD -- <path>
#difference between HEAD and n-th grandparent
git diff HEAD~n HEAD -- <path>
#Another cool feature is whatchanged command
git whatchanged -- <path>
0
To see the diff between handle_questions.php 2 in the working directory and in the repository 1 5 commits back, use:
$ git diff HEAD~5 handle_questions.php
You can use git bisect to track down the 1 commit which introduced a bug.
If you know the file that the change was 3 made in, you can also use git blame <path>
- this will give 2 you ahistory of each line of code in the 1 following format:
SHA (Author Timestamp Line Number) code
From @db_ answer (but shown as an actual 3 example)
I just want to see what difference 2 there is between the current file and the 1 last commit for just a single file.
git diff scripts/processQueue.php
- if( filemtime( $filename ) < time() - 10 ) {
+ $filemtime=filemtime($filename);
+ if( $filemtime < time() - 10 && $filemtime> (time() - 86400))
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.