git log -g --pretty=oneline | grep '}: commit' | awk '{print $1}' | head -1 | xargs git checkout -f

Update the working tree to the latest git commit


0
2010-03-09 16:56:39

These Might Interest You

  • ################################################################################ # get all modified files since last commit and zip them to upload to live server ################################################################################ # delete previous tar output file rm mytarfile.tar -rf #rm c:/tarOutput/*.* -rf # get last commit id and store in variable declare RESULT=$(git log --format="%H" | head -n1) # generate file list and export to tar file git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT $RESULT | xargs tar -rf mytarfile.tar # extract tar files to specified location tar -xf mytarfile.tar -C c:/tarOutput Show Sample Output


    1
    git diff-tree -r --no-commit-id --name-only --diff-filter=ACMRT COMMID_HASH | xargs tar -rf mytarfile.tar
    sarfraznawaz2005 · 2014-03-04 12:16:07 1
  • This is to get the latest version of phpMyAdmin to support scripts to download the latest version of the software if they want to automatically update. Show Sample Output


    -2
    wget http://tools.web4host.net/versions.tmp --quiet -O - | grep PHPMYADMIN | sed 's/PHPMYADMIN=//' | cat
    wr8cr8 · 2011-09-22 04:11:44 0
  • It's pretty common to forgot to commit a files, be it a modification, or a brand new file. If you did forget something, git add the files you want, and then git commit --amend. It will essentially redo the last commit, with the changes you just added. It seeds the commit message with the last commit message by default. You probably shouldn't do this if you've already pushed the commit. Show Sample Output


    14
    git commit --amend
    technicalpickles · 2009-02-27 04:42:44 3
  • Sorts by latest modified files by looking to current directory and all subdirectories Show Sample Output


    1
    find . -name '*pdf*' -print0 | xargs -0 ls -lt | head -20
    fuats · 2013-10-03 21:58:51 0
  • specially usefull for sql scripts with insert / update statements, to add a commit command after n statements executed. Show Sample Output


    2
    ls -l | sed "$(while (( ++i < 5 )); do echo "N;"; done) a -- COMMIT --"
    glaudiston · 2010-03-17 20:12:05 1
  • Will do the merge, but only apply changes to working copy and index; won't commit.


    0
    git merge --no-commit --no-ff
    Pistos · 2009-02-09 18:59:26 0

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: