From 600a1913024e35a1d74c8f59c8acebb17e7afa2b Mon Sep 17 00:00:00 2001 From: pineladsn Date: Wed, 9 May 2018 14:39:01 -0300 Subject: [PATCH] Add rebase commits section --- README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f4fe7da..99f6e08 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ You can also read the [Portuguese](translation/README.pt-br.md) version. * [Staging files](#staging-files) * [Stashing files](#stashing-files) * [Committing files](#committing-files) +* [Rebase commits](#rebase) * [Branching and merging](#branching-and-merging) * [Resetting](#resetting) * [Git remote](#git-remote) @@ -171,7 +172,18 @@ $ git commit -am 'insert commit message' # Amending a commit $ git commit --amend 'new commit message' or no message to maintain previous message -# Squashing commits together +# Squashing commits together using reset --soft +$ git reset --soft HEAD~number_of_commits +$ git commit +** WARNING: this will require force pushing commits, which is OK if this is on a branch before you push to master or create a Pull Request. +``` + +#### Rebase + +Reapply commits on top of another base tip + +```sh +# Rebasing commits $ git rebase -i This will give you an interface on your core editor: # Commands: @@ -182,10 +194,14 @@ This will give you an interface on your core editor: # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell -# Squashing commits together using reset --soft -$ git reset --soft HEAD~number_of_commits -$ git commit -** WARNING: this will require force pushing commits, which is OK if this is on a branch before you push to master or create a Pull Request. +# Rebasing just some last commits +$ git rebase -i HEAD~[number_of_commits] + +# Continue the rebase +$ git rebase --continue + +# Abort the rebase +$ git rebase --abort ``` #### Branching and merging