1


I have been using git for one of my websites and have been pushing my code to a remote repository. This is all well and good however whenever I want to update the production site I need to upload my code through an FTP client.

Current Workflow

This process of making code changes > pushing to a remote repo on GitHub > then uploading via FTP has its downsides when having a team of developers.

Desired Workflow

What I'm looking for is a away to update my files on my hosting server (hostgator) that contains the production files from the master branch of my remote repo. Essentially no use for FTP client.

Guidance needed

I'm sure there is a way however I'm lost in how to do this. Need your help! Thanks as always! :)

Andrew C. Duarte
  • 117
  • 1
  • 13
  • Seems your local git repo located in a different machine with the production server. How does the local machine (which the local git repo located) communicate with the production server except FTP? Is it http or ssh protocol possible? – Marina Liu Jan 15 '18 at 08:52

2 Answers2

1

If you are using Travis along with github for your remote repository, try Travis custom deployment. You just have to add your credentials and deploy command on your `.travis.yml' file.

env:
  global:
    - "FTP_USER=user"
    - "FTP_PASSWORD=password"
after_success:
    "curl --ftp-create-dirs -T uploadfilename -u $FTP_USER:$FTP_PASSWORD ftp://sitename.com/directory/myfile"

Important Note

If you are using a public repository it is very important to encrypt your credentials to the ftp server!

You can have a look at travis documentation:

dstrants
  • 5,645
  • 2
  • 18
  • 27
0

If you have access to your remote server, you can make sure your Git repo is a bare repo, in which case you can add a post-receive hook in order to checkout the repo each time a commit is pushed. See my answer here.

But if your repo on the remote server is directly one with a working tree, then you can enable a push-to-deploy (if the remote Git is 2.4 or more). But that is a bit dangerous if many developers are all pushing to the same repo.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283