How do i see the differences in git files?



  • git man page: http://bit.ly/2nvGNWB

    Let's say i made a change to a file called README.md in my git repository by adding a new line, and I do a git status.

    $ git status
    On branch master
    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:   README.md
    
    no changes added to commit (use "git add" and/or "git commit -a")
    

    Now I want to see what is different between what I have previously commit with README.md and what I just modified, because I may not want to keep the modified copy. Run a git diff, this shows me the diff between what is commited with README.md and what I've just modified. I added the forth line.

    $ git diff 
    diff --git a/README.md b/README.md
    index 1408e61..4ba7d0a 100644
    --- a/README.md
    +++ b/README.md
    @@ -3,3 +3,5 @@ First Line: Today i woke up and went running
     Second Line: When I get back from running I'm tired
     
     Third Line: I got straight to bed
    +
    +Fourth Line: and I dream of running the marathon
    

    If you want to keep the changes, just do a git add <file>, git commit -m "<your message>", as before


Log in to reply
 

© Lightnetics 2024