Here's a not too uncommon task in git that I just can't seem to remember:
Merge specific files from another branch or revision
It's simply checkout out that file on top of the current branch, but I always forget the syntax and try something like
git checkout <branch>:<file> which doesn't work. Then i think, oh, it's a copy, so i try
git checkout <branch>:<file> . which checks the file out but in the current directory. So I think i'm on the right path and try
<localpath> instead of the dot, but that just complains about error: pathspec '<localpath>' did not match any file(s) known to git. And then I finally wise up and google around and re-discover it's just:
git checkout <branch> <file1> <file2> ...
Yeah, that easy. Thanks to Jason Rudolph whose very familiar struggle google pointed me to this time around.
Oh and while I'm at it.
<branch> in the above could be a commit (that nasty hex sig), so you can pick the file state from anywhere in time.
And what if that commit was on another branch how to you look at that log?
git log <branch> of course. And you can even look at the log of branches not currently tracking locally with
git log <remote>/<branch>, but be aware that while
<remote>/<branch> does as the source for the above checkout, using the commit signature does not work until you are tracking that branch locally. If you try the error won't be very informative either:
$ git checkout b35e968bc9105041fd93d901bf8febe858d9847a src/mindtouch.core/service/S3StorageService.csfile(s) known to git.
error: pathspec 'b35e968bc9105041fd93d901bf8febe858d9847ar' did not match any file(s) known to git.
error: pathspec 'src/mindtouch.core/service/S3StorageService.cs' did not match any
Well, hopefully I'll remember to look in my past posts next time I attempt this, because I'm sure i'll have forgotten again.