0

I am fairly new to chef (and git for that matter), so please forgive me if this question is very basic:

Using SVN as my repository, I can use the svn resource to check out a file when running my recipe on a node. Now, I would like to move over to git (I have a local gitlab server) and I would like to do the same, but it seems I will need to check out the full .git repo in my recipe, even if only one file was updated and I wanted to deploy that only?

Do I have that correct or am I missing something?

Thanks!

2
  • Assuming you're doing a git clone on the remote host, you can use --depth 1 to limit the history to a single revision. Commented Jun 12, 2017 at 17:00
  • But that is still the full *.git with all the files in that repository, isn't it? I just want to get a single file from the repository, like httpd.conf for example. Using the subversion resource, I can do: repository svnserver/svn/webserverconf/httpd.conf Commented Jun 12, 2017 at 17:07

2 Answers 2

0

If i am getting your question correctly. In case you have uploading your files first time to the git repo you need to upload the full .git repository.

Other than this if you have created any files which is new in that case only new files or file needs to be pushed to the git repository.

Run below command to check the git related changes.

If you have add git repo on your local machine just run "git status" on the root of your local git repository so it will tell your which files are new and need to be push.

If you are file with the output just run "git add ."

then "git commit -m "your comments related to the file/or changes in that"

and finally run "git push"

Hope it will help you.

Thanks

2
  • Yes, I pushed the full repo to my gitlab server. I now want to use CHEF to pull one file only and not the full repo. So, I am using the git chef resource, but it seems you can only pull the full repo in a recipe and not just one file? Commented Jun 12, 2017 at 19:18
  • yes thats correct. Commented Jun 12, 2017 at 19:20
0

You can do the action :export which doesn't download the .git artifacts.

Refer https://docs.chef.io/resource_git.html

You can retrive a single file from git using below command.

git archive --remote=ssh://host/pathto/repo.git HEAD README.md

Reference

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.