Top Banner
Round 3 - Jacob Jenkins Working with others™ A guide to branching, merging, and rebasing.
22

Working with others using git and Github

Apr 14, 2017

Download

Software

Jacob Jenkins
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Working with others using git and Github

Round 3 - Jacob Jenkins

Working with others™A guide to branching, merging, and rebasing.

Page 2: Working with others using git and Github

Code of Conduct- Branch when creating a new feature.- Keep origin/master working.- Pull before you push.- Rebase with caution.

Page 3: Working with others using git and Github

Branching

So, you have a super cool feature you want to add to your group’s project...

Page 4: Working with others using git and Github

git checkout -b super-cool-featureNow start coding!

Page 5: Working with others using git and Github

Branch Road Rules- Give the branch a meaningful name.- It’s alright for more than one person to work on a branch.- Make sure to pull origin/master before merging back.

How do we merge our feature back into origin/master?

Page 6: Working with others using git and Github

Two options...1. Merge it manually!

$ git checkout master

$ git merge super-cool-branch

2. If you’re using GitHub, submit a pull request!

Create Pull Request

Page 7: Working with others using git and Github

Pull Requests

Page 8: Working with others using git and Github

Pull Requests

Page 9: Working with others using git and Github

Pull Requests

Page 10: Working with others using git and Github

Pull requests are also great for contributing to open source projects.

Page 11: Working with others using git and Github

The magic of pulling before pushing.git pull does a git fetch and a git merge.

What does that mean...

It means changes are applied before you commit, minimizing merge conflicts.

Page 12: Working with others using git and Github

Merge Conflicts- What’s a merge conflict?- How do I solve it?

function superCoolFunction() {

<<<<<<< HEAD

console.log(“Wow, this function is cool”);

=======

console.log(“Wow, this function is awful”);

>>>>>>> negative-attitude

In most cases, you can solve it with your editor.

Page 13: Working with others using git and Github

function superCoolFunction() {

console.log(“Wow, this function is cool”);

}

$ git add supercool.js

$ git commit -m “Make console message positive”

$ git push

Sometimes, it’s not that easy…

Page 14: Working with others using git and Github

RebasingRebasing allows you to rewind the commits in one branch, pull another, and replay them. This is really useful if you made some changes in a branch and want to avoid having to do a merge for tiny changes.

git rebase origin/master

It also has an interactive mode that lets you do a bunch of cool things.

However, YOU MUST USE REBASE WITH CARE.

Page 15: Working with others using git and Github

RebasingRebasing essentially lets you rewrite history, and with great power comes great responsibility.

Thanks Uncle Ben.

Page 16: Working with others using git and Github

Being a good git citizen

Page 17: Working with others using git and Github

Write great commit messages- Be descriptive.- Use the imperative mood in the subject. (e.g Add feature, Fix bug)- Keep the subject line to 50 characters.- Capitalize the first letter of the subject and leave off the period.- Line wrap the message body (extra details) at 72 characters.

Page 18: Working with others using git and Github

Like this, but better

Page 19: Working with others using git and Github

Use GitHub issues- If you find a problem, submit an issue on GitHub.- Use GitHub issues as a sort of todo list.

Page 20: Working with others using git and Github

Issues overviewCurrently open issues

Page 21: Working with others using git and Github

Issues overviewCreating a new issue

Page 22: Working with others using git and Github

For further reading go here!

Fin.