Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Freek Wevers
PLUS
Freek Wevers
Courses Plus Student 14,599 Points

How to use Git with files stored on a SFTP server

The company i'm working for has a couple of websites based on Oracle portal for the back-end. Development on the back-end is done by some guys from another company, but we do the front-end development ourselves.

The problem is that the CSS and javascript files are stored on a production SFTP server and I'm working directly on those files. There is no fool proof backup system whatsoever, which of course isn't a very good idea.

I was thinking of using Git as a backup system, but I don't see how to implement this in our workflow. The problem is that I can't fetch a local copy of the webpages, because they are not separate HTML-files. The pages are generated by Oracle portal.

I would like to make a repo of the SFTP server, but when I start making changes on the files I should take a local copy of the master en work on this local copy. Another problem is that the website points to the SFTP and not to my local copy which I should be making changes to.

Anybody any ideas on how to do this? Any help would be appreciated.

3 Answers

B B
B B
2,934 Points

If you edit the CSS/javascript files on your local computer can't you initiate a git repository and just have it track those files? Unless you have full access to the server you won't be able to run git pull on it, but you could at least commit your changes to the git repository on your local machine so you have a trail of backups to revert to?

Freek Wevers
PLUS
Freek Wevers
Courses Plus Student 14,599 Points

Thanks for your reply.

I can't edit the files on my local machine, because I wouldn't be able to see the effects on the live website. That's why I need to change the files on the SFTP server directly.

What if I indeed copy the server's contents to my local machine, initiate a Git repo there and treat that as my master? When I'm done working on my files on the SFTP server, I could commit the changes I made to my local master, wouldn't I? Is that what you mean?

If that's what you mean, then I guess I could take it a step further and have my local repo synch with a cloud based version of that repo. That way I would have my files and the history of those files safely stored on another server, so my back-up problem would be solved, right?

B B
B B
2,934 Points

Sorry are you sshing into the server to edit these files via command line? Thats definitely odd, but if thats the case you could probably do what you suggested in your second paragraph and pull the files down after you complete your edits and then commit them as backups.

Normally in a FTP scenario you are editing the files locally (even if you can't see the results) and pushing them to the server either manually or automatically, so that was why I provided my first suggestion as once you were done with editing and everything was working, you could commit/push to store as a backup.