Git to see the difference between current and previous version

Source: Internet
Author: User

Http://stackoverflow.com/questions/9903541/finding-diff-between-current-and-last-versions

up vote47down vote

As pointed out in A comment by amalloy, if by ' current and last versions ' you mean the last commit and the Commit before, could simply use

   git Show   
shareedit /td> answered  oct "at 17:46 Nighto1,081< Span class= "Badge2" >921
3
This is the what I am looking for. Great answer. –codemaniak Jan at 22:50
simpler. This should is the accepted Answer. – jbmusso mar 2 at 9:21
6
Use git show HEAD~1 to show the Last-but-one commits, and git show HEAD~2 , etc. for older commits. Show just a single file via git show HEAD~2 my_file . –florian Brucker Mar 3 at 10:43

Assuming "current version" was the working directory (uncommitted modifications) and "last version" was HEAD (last Committe D Modifications for the current branch), simply do

git diff HEAD

Following goes to userCerran

And if you are always skip the staging area -a with when your commit, then you can simply use git diff .

Summary

    1. git diffShows unstaged changes.
    2. git diff --cachedShows staged changes.
    3. git diff HEAD shows all changes (both staged and unstaged).

Source:git-diff (1) Manual Page–cerran

ShareEdit edited  June 0:52 Dheeraj bhaskar11.7k 3< Span class= "Badge2" >3046 answered Mar ' at 8:17charlesb43.3k118141
and if you always skip th E staging Area with  -a  when you commit and then can simply use  git diff . <1>  git diff  shows  unstaged  changes. <2>  git diff--cached  shows  staged   Changes. <3>  git diff HEAD  shows  all  changes ( Both staged and unstaged). Source: git-diff (1) Manual page – cerran Feb 13:16 
This is a good summary. Could is an answer. –user3527975 4 at 18:11

Git to see the difference between current and previous version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.