1

I did sparse checkout through Jenkins. I can see module which I had specified is checkout. Now I want to checkout some other file from remote which is not earlier checkout by jenkins using below command:

git checkout dbo.tmp_ptr1307_exclude_client_ToBePurged.sql which give me error as "did not match any file(s) known to git"

I tried passing sh key as well like: it checkout be4055c069ce9b9abd3baf727cfc65319f6c1dd0 dbo.tmp_ptr1307_exclude_client_ToBePurged.sql give me same error.

Cœur
  • 37,241
  • 25
  • 195
  • 267
jai kunwar
  • 49
  • 1
  • 7
  • Just to clarify... is the file you are looking for included in your sparse checkout? If it's not, then of course Git will not know what you are talking about... you are asking it to find something you explicitly told it not to see. You will need to reconfigure your `sparse-checkout` config file. https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/13738951 – JDB Oct 10 '17 at 18:27
  • @JDB Yes that file is not there while sparse checkout.I am only checking out one folder which has single file. My git repo has thousands of file but while checking out I need only few files form different folder. I just wanted to check out those files instead of checking out all the files. I gueess we just need to update .git folder which should have same as git clone. – jai kunwar Oct 10 '17 at 18:55
  • Never mind - found an option to ignore the sparse-checkout config. – JDB Oct 10 '17 at 19:02

1 Answers1

0

If you want to ignore your sparse-checkout configuration, use the --ignore-skip-worktree-bits flag, like so:

git checkout --ignore-skip-worktree-bits -- dbo.tmp_ptr1307_exclude_client_ToBePurged.sql

In sparse checkout mode, git checkout -- <paths> would update only entries matched by <paths> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and adds back any files in <paths>.

https://git-scm.com/docs/git-checkout#git-checkout---ignore-skip-worktree-bits

JDB
  • 25,172
  • 5
  • 72
  • 123
  • Thanks a lot @JDB it works. One more question can we checkout file in some specific directory? git checkout ea0cf1d80deeb9b92f44aa8caea93b3173d41425 IP_.sql /rollback – jai kunwar Oct 10 '17 at 19:15
  • You can specify a path to the file: `git checkout --ignore-skip-worktree-bits -- path/to/the/file/dbo.tmp_ptr1307_exclude_client_ToBePurged.sql` – JDB Oct 10 '17 at 20:26