user3537395
user3537395

Reputation: 103

Git, pull from branch, override local files in different folder

I know there are loads of questions and answers regarding pulling the changes and I know how to do that.

The question I have is something I have not found so far and here is what I want to do:

I have a site and I don't want to use git only for pulling the changes to the site and I want to do this from a different folder.

For example:

a) /var/www/public_html <--- Location where the site is

b) /home/update_site/ <--- This is where I want to run git from

I don't care about branches, differences or anything on the server itself, none of the work is done on the server and there will never be any commits done or anything like that on the server itself. All I want is to pull the latest changes and override everything on the site and I do not want .git folder or anything related to git to be in the a) location. Imagine using wget for downloading the files.

I was thinking of making a bash script that pulls everything to location b), then do a cp command to copy everything to location a).

Is there a better way of doing this?

Upvotes: 2

Views: 78

Answers (1)

Libin Varghese
Libin Varghese

Reputation: 1744

You could use git archive or git checkout-index

Example: On a local copy

git archive master | tar -x -C /var/www/public_html

OR

git checkout-index -f -a --prefix=/var/www/public_html/

You can also pass the remote repo as an argument, if you don't need a local copy

git archive --remote=ssh://remote_server/remote_repository master | tar -x -C /var/www/public_html

Upvotes: 1

Related Questions