简体   繁体   中英

Jenkinsfile checkout to a specific folder via git command

I want to run this command in the jenkinsfile

git checkout <repo> <folder name>

but I get this error

[git-checkout-example] Running shell script
+ git checkout git@code.in.spdigital.io:sp-digital/jarvis-api.git wahahah
fatal: Not a git repository (or any of the parent directories): .git

Any idea how can I go about doing it in Jenkinsfile? can I checkout the files to a specific folder?

can I checkout the files to a specific folder?

You can checkout files of a specific folder, not *to a specific folder.

See git checkout man page

When <paths> is given, git checkout does not switch branches.
It updates the named paths in the working tree from the index file or from a named <tree-ish> (most often a commit).

git checkout with <paths> is used to restore modified or deleted paths to their original contents from the index or replace paths with the contents from a named <tree-ish> (most often a commit-ish).

But in your case, the issue comes from your current working directory when you are executing git checkout xxx -- path : you need to be in a git repo.

Trying to checkout a repo to a path is called git clone , not git checkout .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM