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 trialJustin Hill
16,642 PointsWebsite deployment and version control
Hello all, Thanks to the Treehouse team for putting together such an awesome library of courses.
Context: I'm a total newbie to web development, but I've completed everything in the Front-End track except for the Sass course, which I plan to work on this weekend.
I'm excited to get started on tinkering with the personal website we created at the beginning of the Front-End course, but I have some basic questions about how this all sort of fits together:
In the Git course, the teacher Tommy referred to the fact that at Treehouse, the master branch is the branch they push out to production on their site. I've created a git repository on GitHub to house all of my website's files remotely, and then I cloned that repository onto my local machine and copied all of my website files into that repository. My question is, how are you able to grab only the files from your master branch and upload only those files to your server (per the Front-End track's instructions, I am hosting my site on Free Web Hosting for Students, and I already know how to use an FTP client like Filezilla to get everything up there, but I'm confused about what the best practice is for differentiating between the "master" version of the files that should be uploaded, and any of the "in progress" files that might be associated with another branch that hasn't been merged onto the master yet). I realize this might be overkill for a simple personal website, but I want to get in the habit of using version control to keep my work organized.
I have seen a few blog posts and whatnot around that give suggestions about installing git directly on your server, or using paid applications like Beanstalk, but I was hoping that somebody more knowledgeable than me could provide some input and point me in the right direction. Thanks again.
3 Answers
Davy Wong
25,470 PointsThe best way is to install git on your webserver and clone the master branch from Github to your webserver. You can then use git to pull in any changed files instead of the entire repository anytime you update your website.
If your webhost doesn't allow you to install git on your webserver, then you can clone just the master branch on your computer, then use FTP to transfer it to your webserver, overwriting the existing files.
Justin Hill
16,642 PointsHm. If anybody else was curious, I think I was over-complicating things very needlessly. I was taking a look at the Git Workshop video that was just posted recently, and the video revealed that I had totally misunderstood the behavior of the "checkout" command.
For some reason, I was thinking that the files that showed up in your file finder/explorer/whatever were always the most recent version of each file, irrespective of whatever branch they were created or modified on (in other words, I thought git was working behind the scenes to capture revision info and that's it). But if you're working on a feature in a separate branch, and then go into the console and use "git checkout master", all of your files change back to their state from the last commit on the master. So, I could just checkout master in my regular old project folder and then all of my stable files are right there, ready to be FTP'ed over to my server. Neat. So if anybody else sees this, disregard my confused comment above.
However, I definitely get why Davy Wong mentioned installing git on the server as being preferable... definitely seems smarter to have git handle things by only pulling the files needed, rather than taking the time to use FTP and either A) hunt down the changed files to be uploaded, or B) spend time overwriting all of the files if I don't feel like doing A. I think I get it now.
Jorge Andrès González Romero
556 PointsMaybe you should use git-ftp (https://github.com/ezyang/git-ftp) very useful to push files on a server with only FTP access.