Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Viewing history and diffs

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 549
    Comment on it
    Previous Git Blogs


    1. Intialize git repostiory
    2. First Commit
    3. Two tree architecture and Three tree architecture
    4. Best basic practices for writing commit messages
    5. Viewing the commit logs
    6. Git Basic WorkFlow
    7. What is HEAD pointer in GIT
    8. Git Configuration
    9. Viewing history
    10. Updating a file and adding it to repository

     naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git log 
    commit 34d195335ce1093085045cb148bb1765f4b01a79
    Author: naveenkumar 
    Date:   Wed Dec 16 11:16:07 2015 +0530
    
        Update comment added
    
    commit e95efc2d8e94f72f13e1b578b1d80451e8cf2ac8
    Author: naveenkumar 
    Date:   Wed Dec 16 10:49:52 2015 +0530
    
        Readme file added
    
    commit a67edfaa870430ae58dd6d6e8cea68f0c9a08c0a
    Author: Naveen 
    Date:   Mon Dec 14 13:44:18 2015 +0530
    
        my initial commit
    

    Most recent commit will always br on top

    If I want to find out what has changed between these commits I can use

     git diff

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git diff e95efc..34d195

    Note : e95efc & 34d195 is a first 6 charcters of commit id

    Git Display
    diff --git a/readme.txt b/readme.txt
    index 2ba180a..bda49b4 100644
    --- a/readme.txt
    +++ b/readme.txt
    @@ -1 +1,2 @@
     Please Read me
    +MY new changes
    

    +MY new changes this text has been added as it got + sign on front of it

    always Working with SHA~1 hashes could be difficult there are other ways we could do the same

    The lates commit is known as HEAD, and I can go back prevoius commit with using tilt HEAD~1 i.e one commit back from the HEAD, So we can do

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git diff HEAD~1..HEAD
    Git Dispaly:
    diff --git a/readme.txt b/readme.txt
    index 2ba180a..bda49b4 100644
    --- a/readme.txt
    +++ b/readme.txt
    @@ -1 +1,2 @@
     Please Read me
    +MY new changes
    

    This also works

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git diff HEAD~1..
    Git Display
    diff --git a/readme.txt b/readme.txt
    index 2ba180a..bda49b4 100644
    --- a/readme.txt
    +++ b/readme.txt
    @@ -1 +1,2 @@
     Please Read me
    +MY new changes
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: