add a change in git that you have just checked using git diff

It's useful to run run git st before you commit changes. To see an individual commit it's good practice to type git diff . If you are happy with what you see, to add the file, just type ^diff^add

By: binaryten
2012-10-09 21:51:05

These Might Interest You

  • If you have ever edited a locally checked out version of a file to tweak it for testing purposes, and came back to it over a weekend, you might have forgotten what you exactly changed. This command helps you see the differences between the the checked in SVN version, and the one you tweaked. Show Sample Output

    svn diff <FILE>
    bbbco · 2012-01-30 16:47:48 5
  • get subversion diff output without distracting whitespace changes. good for when you are cleaning up code to make sure you didn't change anything important. also useful when working with old code, or someone else's code.

    svn diff --diff-cmd diff -x -uw /path/to/file
    katylava · 2009-02-10 20:39:54 1
  • from a svn repo, print a log, with diff, of each commit touching a given file

    FILE=somefile.js; LOG=~/changes.diff; truncate -s0 ${LOG}; for change in $(svn log ${FILE} | awk -F' | ' '/^r[0-9]+/{print $1}'); do svn log -c ${change} >> ${LOG}; printf "\n" >> ${LOG}; svn diff -c ${change} >> ${LOG}; printf "\n\n\n" >> ${LOG}; done
    hochmeister · 2014-12-23 20:00:54 1
  • This form is used in patches, svn, git etc. And I've created an alias for it: alias diff='diff -Naur --strip-trailing-cr' The latter option is especially useful, when somebody in team works in Windows; could be also used in commands like svn diff --diff-cmd 'diff --strip-trailing-cr'... Show Sample Output

    diff -Naur --strip-trailing-cr
    ruslan · 2011-02-10 14:32:42 0
  • When running a long `diff -r` over folders, this simulates a "verbose" mode where you can see where diff is in the tree. Replace $file with the first part of the path being compared.

    lsof -c diff -o -r1 | grep $file
    d0g · 2014-01-29 18:35:28 1
  • Checks if a web page has changed. Put it into cron to check periodically. Change http://www.page.de/test.html and mail@mail.de for your needs.

    HTMLTEXT=$( curl -s http://www.page.de/test.html > /tmp/new.html ; diff /tmp/new.html /tmp/old.html ); if [ "x$HTMLTEXT" != x ] ; then echo $HTMLTEXT | mail -s "Page has changed." mail@mail.de ; fi ; mv /tmp/new.html /tmp/old.html
    Emzy · 2010-07-04 21:45:37 1

What Others Think

^d exists my shell?
t3o · 292 weeks ago
Yes, It would be work in almost all popular shells. It's not special command. About characters number: echo 'dfaklfjdkaslfdlafdsafdasfdsalfjdaklsjfdklasklfdaslfdaskfdasjlfjdaslkfjdaskljfklsdajfkldasjfkldasjklfdjasklfdjsaklfdjaskljfkldasjklfdasjlkfdasjljklfads' ^dfaklfjdkaslfdlafdsafdasfdsalfjdaklsjfdklasklfdaslfdaskfdasjlfjdaslkfjdaskljfklsdajfkldasjfkldasjklfdjasklfdjsaklfdjaskljfkldasjklfdasjlkfdasjljklfads^test Works fine!
DNI · 284 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: