working with others using git and github

Post on 14-Apr-2017

288 Views

Category:

Software

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Round 3 - Jacob Jenkins

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

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

Branching

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

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

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?

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

Pull Requests

Pull Requests

Pull Requests

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

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.

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.

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…

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.

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

Thanks Uncle Ben.

Being a good git citizen

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.

Like this, but better

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

Issues overviewCurrently open issues

Issues overviewCreating a new issue

For further reading go here!

Fin.

top related