Getting into Git
It's no secret that when it comes to workflow, my methods have always been a little 'fragile'. That is not to say that my client's websites, or my local design files are at any risk - both my server and my computer run comprehensive backup systems.
What has been lacking is a proper solution for working on websites locally (I've generally preferred to use my development server for building sites). And on top of this, I've never got into version control of any kind, or been able to involve other developers in the process of building a site.
With the start of another new year I've finally decided enough is enough and I need to 'upskill'! I've setup MAMP as a local development environment - it seems to work really well, and I've worked through establishing a Git workflow which works for me. I've described it below, briefly, just incase it's of use to anyone else:
Create Directory on Server
First I create the website directory structure on my live server, like this:
- mkdir /srv/sitename
- mkdir /srv/
sitename/public - mkdir /srv/
sitename/public/htdocs
Move to Root Directory
- cd /srv/
sitename/public/htdocs
Git Init & Create readme.md
- git init
- sudo nano readme.md (enter a description and save)
Add Files to Git and Commit
- git add .
- git commit
Create a Repo on GitHub
- Create a new repo on GitHub with appropriate name
Send Files to GitHub
- git remote add origin repo.url
- Clone repo to local dev environment (use GitHub Desktop for this)
Make Changes to Local Files
- Edit locally (build site etc.)
Push to GitHub
- Use GitHub Desktop to manage this
Pull New Files to Server
- git pull origin master