Skip to content

Instantly share code, notes, and snippets.

@chrisbelyea
Last active March 14, 2018 18:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbelyea/90146b7d6c1a67b072347d418154dbb5 to your computer and use it in GitHub Desktop.
Save chrisbelyea/90146b7d6c1a67b072347d418154dbb5 to your computer and use it in GitHub Desktop.
A Git Workflow Using `rebase`
Why Squash?
1: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=why_squash_1.md"></script>
2: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=why_squash_2.md"></script>
3: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=why_squash_3.md"></script>
Setup
2: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=setup_2.md"></script>
3: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=setup_3.md"></script>
4: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?file=setup_4.md"></script>
Workflow
Step 1: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_1.md"></script>
Step 2: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_2.md"></script>
Step 3: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_3.md"></script>
Step 5: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_5.md"></script>
Step 6a: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_6a.md"></script>
Step 6b: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_6b.md"></script>
Step 6c: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_6c.md"></script>
Step 7a: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_7a.md"></script>
Step 7b: <script src="https://gist.github.com/chrisbelyea/90146b7d6c1a67b072347d418154dbb5.js?step_7b.md"></script>
git clone git@github.com:chrisbelyea/pebble.git
cd pebble
git remote add upstream git@github.com:singlestone/pebble.git
origin	git@github.com:chrisbelyea/pebble.git (fetch)
origin	git@github.com:chrisbelyea/pebble.git (push)
upstream	git@github.com:singlestone/pebble.git (fetch)
upstream	git@github.com:singlestone/pebble.git (push)
git fetch upstream
git checkout master
git merge upstream/master
git checkout -b issue-1
git fetch upstream
# Now your local `upstream/master` branch contains any new commits that are in upstream's master branch.
git rebase --interactive upstream/master
pick c42629e Add feature XYZ
pick 6fa213d Make an update
pick fdcc8a6 Do some more stuff

# Rebase e342e4d..fdcc8a6 onto e342e4d (3 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
pick c42629e Add feature XYZ
squash 6fa213d Make an update
squash fdcc8a6 Do some more stuff

# Rebase e342e4d..fdcc8a6 onto e342e4d (3 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
git push --set-upstream origin issue-1
git push --force origin issue-1
4d7269c (HEAD -> issue-1) added missing semicolon, lol
ae37a28 my code is broken
30cd73d syntax error ugh
cf5ff68 syntax error2
44962e5 syntax error
26a6423 Broke linter
2a9a75d Fix issue in method
7d0be0e Get tests passing
bd23847 Add some more code
8f34218 Implement feature XYZ
4cb7063 (master) Initial commit
c27766b (HEAD -> issue-1) Implement feature XYZ
4cb7063 (master) Initial commit
commit c27766b4006fa5b1680803748ecfae07b17f1454 (HEAD -> issue-1)
Author: Chris Belyea <chris@chrisbelyea.com>
Date:   Fri Jan 12 10:42:08 2018 -0500

    Implement feature XYZ

    Implements feature XYZ which does blah blah blah. This includes:
    - this
    - that, and
    - the other

    Closes #1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment