Skip to content

Instantly share code, notes, and snippets.

@elyezer
Forked from omaciel/gist:7811339
Last active December 31, 2015 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elyezer/7933471 to your computer and use it in GitHub Desktop.
Save elyezer/7933471 to your computer and use it in GitHub Desktop.

Fork It

  • Add Robottelo as a remote repository to your fork
(master) $ git remote add upstream git@github.com:omaciel/robottelo.git
  • Fetch latest upstream code
(master) $ git fetch upstream
  • Rebase your fork's master repo to match upstream's
(master) $ git rebase upstream/master

Branch it before you work

  • Create new local repo to work on issue or feature
(master) $ git checkout -b branch_name
  • Make all your changes in the local branch_name branch and commit with a nice, short subject and a detailed message
(branch_name) $ git add <all modified or new files>
(branch_name) $ git commit

Adding feature so and so to module blah.

Here I will add more information about what the entire commit is about.
  • Ready to push your changes for a PR?
(branch_name) $ git push origin branch_name
  • Now use Github's web UI to create your PR.

Updating a Pull Request?

  • Need to make more changes either because you received feedback for your PR or because you're not done yet?
(branch_name) $ git add <all modified or new files>
(branch_name) $ git ci --amend

* By using --amend you get to keep all your changes as one single commit, which is much cleaner imho :)

What if Github website says that your PR cannot be merged?

  • First, let's rebase your master to reflect upstream's master
(branch_name) $ git checkout master
(master) $ git fetch upstream
(master) $ git rebase upstream/master
(master) $ git push
  • Now, let's rebase our working directory against your master
(master) $ git checkout branch_name
(branch_name) $ git rebase master
  • Push your rebased branch_name back to Github
(branch_name) $ git push origin branch_name
  • Git complaining about rebase because commit history is being changed? Use the --force Luke
(branch_name) $ git push origin branch_name --force

Picky Rebase?

  • Got to handle some issues with rebase? First, edit the offending file to resolve the conflict. Next, add it and commit it with --amend
(branch_name) $ git add <offending files>
(branch_name) $ git commit --amend
  • Push it back to Github as explained before
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment