InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Git tutorials

  • Github for beginners
  • Undo last commit
  • List git branches
  • Git checkout remote branch
  • Diff two branches
  • Show log of one user's commits
  • View diff for a given commit id
  • Setup password less git push for github
  • Git - Check if a hash is valid
  • Git - display specific length commit hash
  • Git - rename local branch
  • Git create branch
  • Git delete branch
  • Git detached head
  • Git display info of last commit (HEAD) in one line
  • Git display local HEAD location
  • Git log with file names
  • Git show details of a commit hash
 
  • Home
  • > Tutorials
  • > Git

Git – how to view diff for a given commit id

By admin on Dec 2, 2015

Diff commit id with its first parent commit id

Here are some approaches to view diff between first parent of commit id and commit id. We’ll use 6680c1b29ea79bf33ac6bd31578755c7c514ed3e as commit for the purpose of this article.

  1. Using git diff

    $ git diff 6680c1b29ea79bf33ac6bd31578755c7c514ed3e^ 6680c1b29ea79bf33ac6bd31578755c7c514ed3e
    //or
    $ git diff 6680c1b29ea79bf33ac6bd31578755c7c514ed3e^!
    
  2. Using git diff-tree

    $ git diff-tree -p 6680c1b29ea79bf33ac6bd31578755c7c514ed3e
    
  3. Using git show

    $ git show --color --pretty=format:%b 6680c1b29ea79bf33ac6bd31578755c7c514ed3e
    

Diff a commit id with repository head

$ git diff 6680c1b29ea79bf33ac6bd31578755c7c514ed3e

Diff of head commit

$ git diff HEAD^ HEAD 

Example showing diff of a commit id

Follow these steps to see the diff of a commit id.

  1. Clone any git repository. We’ll clone jquery repository.

    $ git clone https://github.com/jquery/jquery
    $ cd jquery
    
  2. Run git log to view some recent commit ids. Run the following command for view diff for a commit id (6680c1b29ea79bf33ac6bd31578755c7c514ed3e).

    $ git diff 6680c1b29ea79bf33ac6bd31578755c7c514ed3e^ 6680c1b29ea79bf33ac6bd31578755c7c514ed3e
    

    Here is initial portion of the outcome.

    diff --git a/src/attributes/attr.js b/src/attributes/attr.js
    index ae48676..00b0848 100644
    --- a/src/attributes/attr.js
    +++ b/src/attributes/attr.js
    @@ -7,7 +7,14 @@ define( [
     ], function( jQuery, access, support, rnotwhite ) {
     
     var boolHook,
    -       attrHandle = jQuery.expr.attrHandle;
    +       attrHandle = jQuery.expr.attrHandle,
    

Suggested posts:

  1. How to recover svn lost password on Linux
  2. How to disable sleep during android usb debugging
  3. How to change twitter handle and its impact on traffic
  4. Git log with file names
  5. Debug javascript using node-inspector, node-debug, nodemon and Chrome
  6. Vim – highlight and move to matching bracket
  7. Git – Check if a hash is valid
  8. Svn – short diff without context
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Git, Linux, Mac, Tutorials, Ubuntu Linux
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress