The document discusses adding source control to development workflows. It recommends using a version control system like Git to manage code and collaborate with others. It provides instructions for setting up a local Git repository, branching, committing changes, merging branches, and pushing code to remote repositories hosted on servers or GitHub. The document aims to demonstrate how source control can improve productivity and make development workflows more robust.
4. Adding Source Control To Your Life
Words worth remembering
init
clone
checkout
branch
fetch
diff
commit
pull
push
revert
Sunday, May 19, 13
5. Coding without source control is like ...
Adding Source Control To Your Life
photographer Emily West (Courtney)
Sunday, May 19, 13
6. Pick a version control system
git, subversion (svn), cvs, mercurial, and many more
Adding Source Control To Your Life
Sunday, May 19, 13
7. What do I do with it?
Adding Source Control To Your Life
domain.comlaptop / dev
New header
Sidebar widget
Facebook feed
importer
Work on different project/features,
switch between them seamlessly,
merge them together without missing anything
Sunday, May 19, 13
8. Adding github.com and staging branch
Adding Source Control To Your Life
laptop / dev
New header
Sidebar widget
Really cool
facebook thingy
laptop / dev
github repo
pull requests
branches
staging server
branch testing
git pull
production server
branch
git pull
pull/push
pull/push
pull
pull
Sunday, May 19, 13
9. Because you want to work
with other smart people
who can help.
Adding Source Control To Your Life
Sunday, May 19, 13
10. Create local repo
Adding Source Control To Your Life
Let¡¯s talk about a simple example, local repo
http://git-scm.com/downloads
Sunday, May 19, 13
12. Learn to branch
git checkout master
git checkout -b some-new-feature
<edit files>
git status
git diff
git commit -a -m ¡®Edit theme for new cool feature¡¯
<another edit>
git commit -a -m ¡®Forgot the blue border¡¯
Adding Source Control To Your Life
* Don¡¯t commit it to production unless it¡¯s ready to go live
Example:
Sunday, May 19, 13
16. Push to remote using ssh
Here are two ways
A) push to a bare repo on server then pull to another working non-bare repo
Or B) push from local branch to a branch on non-bare repo then merge that branch into checked out /
production branch.
B) Initial setup
ssh me@server.com
cd /var/www/html/
git init domain.com
- at this point has no working branches, not even master. Only after initial push below
On local - one time, add remote server repo
git branch laptop - create a local dev branch
git remote add theserver me@server.com:/var/www/html/domain.com/.git
git remote show theserver
git push theserver laptop
On server - one time, after initial push from local, set up working branch
git checkout laptop
git branch production
Adding Source Control To Your Life
Sunday, May 19, 13
17. Push to remote using ssh
B) Work flow after initial setup
On local - in dev branch ¡®laptop¡¯
<edit files>
git commit -am ¡®changed code¡¯
git push theserver laptop
On server - when want changes to go live, merge the branch into working branch
git diff production laptop (show what is changing first)
git merge laptop production (do the merge)
Adding Source Control To Your Life
Sunday, May 19, 13
18. Push to remote using ssh
How it get¡¯s more complicated from there ...
add other humans
add testing environments
add staging environments
add customers with issues, darn those customers!
fast iterations, push a lot, how to code review, test, etc
Adding Source Control To Your Life
Sunday, May 19, 13
19. Push local to github repo
github.com
Create account
Create repository
Adding Source Control To Your Life
Sunday, May 19, 13
20. Push local to github repo
github.com
Create account
Create repository
Adding Source Control To Your Life
Sunday, May 19, 13
21. Push local to github repo
Step 2
ssh-keygen -r rsa -C "email@domain.com"
Add ssh key to github ssh keys
https://help.github.com/articles/generating-ssh-keys
Step 3 - local dev
git init domain.com
cd domain.com
<add files>
git add .
git commit -a -m 'Initial commit'
Adding Source Control To Your Life
Sunday, May 19, 13
22. Push local to github repo
Step 4
git remote add github git@github.com:markkelnar/domain.com.git
git remote show github
git pull github master
git push github master
Adding Source Control To Your Life
Example SSH repo locator
Sunday, May 19, 13
23. Pull from github repo
Step 5 (on the server, one time setup)
ssh-keygen -t rsa -C "email@domain.com"
cd /var/www/html/
git init domain.com
git remote add github git@github.com:markkelnar/domain.com.git
git remote show github
Step 6
git pull github master
Adding Source Control To Your Life
Sunday, May 19, 13
26. Common Excuses (end...)
I heard it's hard.
I¡¯m a solo developer.
I don't have money.
I don't have time.
Adding Source Control To Your Life
Sunday, May 19, 13
27. If time for more time ...
What about staging branches?
What about pull requests?
Adding Source Control To Your Life
feature
branches
staging
branch
production
branch
bug fixes
pull request
pull request
Sunday, May 19, 13
28. Resources
Adding Source Control To Your Life
http://git-scm.com/downloads
https://help.github.com/articles/set-up-git
https://help.github.com/articles/generating-ssh-keys
http://code.google.com/p/tortoisegit/
Sunday, May 19, 13