- 10 min | what is a pull request, and why are we using it.
- 25 min | walk thru of what the process looks like
- 10 min | integration with codeship, and plans for the future
- 15 min | questions
###What is a Pull Request?
- PR's are a feature of GitHub, not GIT.
- PR's are just a fancy diff between two branches.
- PR's provide a venue for feedback and testing.
- PR's can be a testing gate for CI systems (codeship, travis, jenkins, et cetera.)
###Why SHS-Web is using PRs
- Master must be deployable.
- Humans make mistakes.
- Our team is growing, and code reviews are helpful.
###Rebasing. Why not just git pull
?
Lets understand the problem first:
- What does
git pull
actually do? pull = fetch + merge- fetch = update your tracking branches
- merge = create a commit that blends two branches
- GOTCHA: combine their history using timestamps!
This has some cofusing results. Especially when you're not done yet!
- Your INCOMPLETE feture is now split into diff parts of the history by changes in master. Weak.
* e589d92 - feature apples! (6 minutes ago) <Dean Shelton>
* fe21613 - Merge branch 'master' into feature (9 minutes ago) <Dean Shelton>
|\
| * b3891f9 - master-SUPER-IMPORTANT-THING-YOU-NEED (39 minutes ago) <GARY>
| * 6de3722 - master-cucumber! (39 minutes ago) <GARY>
* | d90186c - feature strawb (38 minutes ago) <Dean Shelton>
* | 3e72b4b - feature-bananas! (40 minutes ago) <Dean Shelton>
|/
* 57fc63c - initial commit! (41 minutes ago) <Dean Shelton>
###How does Rebasing solve this?
git pull --rebase origin master
would have given us this:
* e589d92 - (feature) feature apples! (6 minutes ago) <Dean Shelton>
|\
| * d90186c - feature strawb (38 minutes ago) <Dean Shelton>
| * 3e72b4b - feature-bananas! (40 minutes ago) <Dean Shelton>
* | b3891f9 - master-SUPER-IMPORTANT-THING-YOU-NEED (39 minutes ago) <GARY>
* | 6de3722 - master-cucumber! (39 minutes ago) <GARY>
|/
* 57fc63c - initial commit! (41 minutes ago) <Dean Shelton>
Note: All of your feature work is together! As it should be. You're not done, and may need to edit your commits before you're ready to merge.
Interactive Rebase
git rebase -i HEAD~2
Rewind 2 commits back
git rebase -i master
Rewind since your current branched diverged from master.
###What does the process look like?
- Joe creates a local feature branch git checkout -b my_feature_branch_name`
- Joe runs
npm run rebase
to get up-to-date with origin master - Joe does some work and makes a commit
git add . && git commit -m 'changed something'
- Gary merges a pull request into master with super important changes
- Joe does a rebase
git pull --rebase origin master
(ornpm run rebase
) - Joe resolves a merge conflict, and continues working.
- Joe makes 3 more commits
- Joe wants to PR his changes, but some of his commits before the rebase make the history confusing.
- Joes does an interactive rebase,
git rebase -i master
to combine two commits into one, and reword one of his commit messages. - Joe pushes his code as a feature branch on origin
git push origin my_feature_branch_name
- Joe opens his repo in github and creates the pull request.
- Joes tests are green, and he merges his code
git push origin master
git merge
orgit pull
without using--rebase