Wednesday, July 3, 2013

Handy git tricks

Using Git is a blessing, truly it is. Today is just one of those days when I feel like chopping a limb off because git can't understand what I want it to do.
"Restore a file I deleted from my ide, then revert it to its state when I added that line in, then checkout a single file blah blah jabber jabber"

Each time I discover a neat trick to do what I want in git, I shall henceforth make a note of it here :)

  1. Restore a file that you deleted by accident in the repo or Undo all the changes in a file but haven't committed yet.
  git checkout HEAD^ <path to file>

This should bring the file back to the state it is in in the remote repo.

  2.  List all the files included in a commit

git log master

find the commit reference from here eg: 7bdf3a80243c7029508357c45bf4b918ce2bab86
 
git show --name-only 7bdf3a80243c7029508357c45bf4b918ce2bab86

No comments:

Post a Comment