Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add support for "git checkout <sha> -- file" #177

wants to merge 2 commits into


None yet
4 participants

jamill commented Jul 11, 2013

Add support for the Git command:

git checkout <sha> -- file

For example, to checkout foo.txt from the changeset HEAD, it would be:

git checkout HEAD -- foo.txt

It would be nice if the API also exposed a parameter to specify the output path (i.e. the path the file is checked out to, which by default is the path the file is on the revision).

This requires handling of line endings (CRLF, CR and LF conversions).


nulltoken commented Jan 8, 2013

@ben, @jamill Am I correct when thinking that this feature request could now be deal with?


ben commented Jan 8, 2013

Yeah, I'll put it on my list. ✔️


nulltoken commented Jul 11, 2013

This should also be able to checkout a pathspec or a dir and handle following cases

git checkout <treeish> -- /path/to/dir
git checkout -- '*.c'

@nulltoken nulltoken referenced this pull request Jul 11, 2013


sparse checkout #462


jamill commented Jul 11, 2013

I have started working on adding paths to checkout, but it is not ready yet.


jamill commented Jul 11, 2013

This is still a bit of WIP, but I wanted to put up my current progress in case there is any feedback on the direction I am going.


ethomson commented Jul 15, 2013

@jamill This seems pretty straightforward! Excited to have this support.


nulltoken commented Jul 18, 2013

@jamill Makes indeed some sense to separate the standard checkout behaviour (which moves HEAD) from this one.

Two (little?) comments:

  • Could you please add a <para/> in the xml doc explaining that this flavour of Checkout won't move the HEAD?
  • Could you also introduce a new CheckoutOptions collect param and move the optional params of this new method into it? We'll align the Checkout() methods to make them rely as well on this new type in a future PR.

jamill added some commits Jul 11, 2013

CheckoutPaths method should use CheckoutOptions parameter collection …

This change removes obsoleted methods that used previous "CheckoutOptions"
parameter (replaced with CheckoutModifiers type) and changes the
CheckoutPaths method to use new type for common parameter options.

jamill commented Jul 19, 2013

@nulltoken Updated with new xml documentation and repurposed CheckoutOptions to be a new collection parameter (as a separate commit). As part of this I removed all of the obsoleted methods that depended on the previous CheckoutOptions type.


nulltoken commented Aug 4, 2013

@jamill Introduction of the CheckoutOptions type has been manually merged in. Thanks!

@nulltoken nulltoken closed this Aug 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment