Essential Git For Developers
By:
Essential Git For Developers By: Adam Culp Twitter: @ adamculp - - PowerPoint PPT Presentation
Essential Git For Developers By: Adam Culp Twitter: @ adamculp https://joind.in/ 13311 Essential Git For Developers About me PHP 5.3 Certified Work at Zend Technologies Organizer SoFloPHP (South Florida) Organized
By:
2
–
PHP 5.3 Certified
–
Work at Zend Technologies
–
Organizer SoFloPHP (South Florida)
–
Organized SunshinePHP (Miami)
–
Long distance runner
–
Judo Black Belt Instructor
3
–
Everything requires iteration to do well: (practice makes perfect)
4
–
No centralization
–
Each clone = full repository
–
Branching and Merging work
–
Fast
–
Files to be committed are “staged” first
–
Free and Open Source
–
Flexible workflow
5
–
As files and the changes made to each file.
Version 1 Version 2 Version 3 Version 4 Version 5 File A File B File C Diff 1 Diff 1 Diff 2 Diff 1 Diff 2 Diff 2 Diff 3
6
–
As whole files, not files + diffs.
Version 1 Version 2 Version 3 Version 4 Version 5 File A File B File C File A1 File A2 File B1 File B2 File C1 File C2 File C3 File A1 File A2 File B File B File C2 Green means whole file, yellow means pointer to previous whole file.
7
Shared Repository Developer Developer Developer
8
Blessed Repository Integration Manager Developer Public Developer Public Developer Private Developer Private
9
Blessed Repository Dictator Developer Developer Developer Developer Lieutenant Lieutenant
10
–
One repository, everything in one basket.
Developer Local Repository
11
12
–
A bunch of repositories!
Repository Repository Repository Repository
13
–
Repositories can connect in all directions.
Repository Repository Repository Repository
14
–
git config
–
git init
–
git clone
–
git status
–
git add
–
git commit
–
git log or show
–
git branch
–
git checkout
–
git merge
–
git pull or push
15
–
Adding '-h' to any command will return help on usage.
16
–
Easily set your information to accompany commits.
–
Generally a one time thing.
17
–
Instruct Git to track project by simply 'git init'.
–
No more excuses! Version all the things!
18
–
Creates new repository based on another.
–
Cloned repository becomes “Origin”.
19
–
Below we clone a repo from github.
–
We address the .git directory.
–
Specify where to put it.
20
–
Provides status of resources in the tracked project.
21
–
Below 'git status' informs us of untracked files after created.
22
–
Stages files to be committed.
23
–
A 'git commit' includes all “staged” files.
–
Use '-m' to store a message with the commit.
24
–
A commit should be:
– Always included – Short – Informative
25
–
Shows history of prior commits.
–
We've only done one, and here it is:
26
–
Hash optional, will show previous by default.
–
Shows commit + diff view of files.
27
–
We did a 'git add' for file #2, and modified file 1.
28
–
We did a 'git add' for modified file 1.
29
–
We did a 'git add' for new file 3.
30
–
All staged files were added.
–
A 'git status' reveals nothing new or different.
31
–
Git doesn't use numbers like 1, 2, 3...
–
Instead uses hashes like 6e7e6999c879f460b5e1d7e29ffe9907062ec20a
32
–
Should not be working in the 'master' branch.
–
'master' should be pristine version.
33
–
Shows a list of existing branches.
–
The * indicates active branch.
34
–
Creates new branch.
–
Checkout -b checks out after creation.
–
Below we create a 'development' branch.
–
New branch has same state as active/specified branch.
35
–
Include “-b” flag to create new branch.
–
Switches to a specified branch.
–
Branches carry own state.
–
In file browser file contents different.
36
–
A file has been edited, but not committed.
–
We are in 'development' branch.
–
What if we 'git checkout master'?
37
–
Merges uncommitted content on checkout.
–
Does NOT merge over newly created files. (changes only)
–
Conflicts get exciting. (Not covered in this talk.)
38
–
On 'git checkout development' and commit:
master development
39
–
Commit only done on active branch.
–
Master branch is unchanged. ('git log' shown below)
–
Master files do not contain merged changes.
master development
40
–
Git merges specified branch into active branch.
–
We merge change from development to master.
41
–
Merges individual commits into flow as if a checkout never occurred.
42
–
We can exclude:
–
Simply add excluded content to the file '.gitignore'.
43
–
Conventions:
44
–
No code leaves {user}-development unless finished and stable.
–
Do NOT merge conflicts into any public branch.
45
–
Before merging changes to public development:
– Should be no conflicts.
– Fix conflicts
46
–
Typically {user}-development branches remain private.
–
Development, Staging, and Master are public and entire team can view state/commits.
47
–
Git is ideal for team development
48
–
Project/ticket assigned, create branch
–
Start coding.
–
Commit often.
Checkout dev. to private {user}-development Project assigned
49
–
Regularly commit code.
–
Regularly pull from origin.
Checkout dev. to private {user}-development Multiple commits Coding Project assigned
50
–
Development completed, ready for QA testing.
Checkout dev. to private {user}-development Merge changes to development Multiple commits Coding Tests pass Project assigned
51
–
Testing done in development branch.
–
Failed developer picks up on {user}-development. →
–
Bug fixed re-push to development. →
Testing from development Test passed Testing assigned no Return to developer flow
52
–
Testing done in development branch.
–
Success merge to staging →
Testing from development Merge to staging Test passed Testing assigned yes no Return to developer flow
53
–
Regression testing done in staging branch.
–
Testing failed:
–
Code to fix bug
Regression testing In staging Test passed Deploy assigned no Temp branch created
54
–
Send fix back for regression testing done in staging branch.
Regression testing In staging Test passed Deploy assigned no Temp branch created Bug fixed
55
–
If regression tests pass:
Regression testing In staging Merge to master Test passed Deploy assigned yes no Temp branch created Bug fixed
56
–
All is good, create annotated tag.
Regression testing In staging Merge to master Test passed Deploy assigned yes no Temp branch created Bug fixed Tag created
57
–
Pretty similar, but no staging.
–
Note: Still use {user}-development per task/project/ticket.
{user}-development Merge to development Test passed Project assigned Tag created Test passed Merge to master
58
–
gitk
–
gitx
–
git-cola
–
SmartGit
–
GitEye
–
TortoiseGit
–
IDE
– Zend Studio – Aptana
59
–
Great place to share code.
–
Promotes collaboration
–
API enhances connectivity and use
–
Awesome plugins
–
Easy to use
60
–
Standard 'git clone' command
–
Now have a clone local to work on.
–
Follow workflow as shown earlier.
61
–
Always use source control!!!
–
Git is an easy solution, just 'git init'.
–
Plan a workflow and stick with it...ALWAYS!
–
3rd party repositories = backed up
–
Git easy to connect to from anywhere.
–
Love iteration!
62
–
http://nvie.com/posts/a-successful-git-branching-model/
–
http://github.com
–
http://training.github.com/
–
https://bitbucket.org/
–
http://git-scm.com
Essential Git For Developers
–
Please rate at: https://joind.in/13311