From 1873dd832863353c0153c62bc001bc7dc2e0d428 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 11 Mar 2019 09:37:18 -0500 Subject: [PATCH] Add Pulling In Changes During An Interactive Rebase as a git til --- README.md | 3 +- ...in-changes-during-an-interactive-rebase.md | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 git/pulling-in-changes-during-an-interactive-rebase.md diff --git a/README.md b/README.md index bfd704c..f512968 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/). For a steady stream of TILs from a variety of rocketeers, checkout [til.hashrocket.com](https://til.hashrocket.com/). -_778 TILs and counting..._ +_779 TILs and counting..._ --- @@ -198,6 +198,7 @@ _778 TILs and counting..._ - [List Most Git Commands](git/list-most-git-commands.md) - [List Untracked Files](git/list-untracked-files.md) - [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md) +- [Pulling In Changes During An Interactive Rebase](git/pulling-in-changes-during-an-interactive-rebase.md) - [Rebase Commits With An Arbitrary Command](git/rebase-commits-with-an-arbitrary-command.md) - [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md) - [Rename A Remote](git/rename-a-remote.md) diff --git a/git/pulling-in-changes-during-an-interactive-rebase.md b/git/pulling-in-changes-during-an-interactive-rebase.md new file mode 100644 index 0000000..ce32320 --- /dev/null +++ b/git/pulling-in-changes-during-an-interactive-rebase.md @@ -0,0 +1,33 @@ +# Pulling In Changes During An Interactive Rebase + +My standard workflow when doing feature development is to checkout a feature +branch and commit changes as I go. When the feature is finished, I clean up +the commit history with an interactive rebase and then integrate those +changes with `master`. + +I initiate the interactive rebase like this (while on the feature branch): + +``` +$ git rebase -i master +``` + +This allows me to squash, fixup, and delete commits that I've made since +checking out this branch from `master`. + +It is important to note that an another thing will happen seemingly behind +the scenes. Any commits on `master` since the feature branch was checked out +will be applied to the feature branch before the effects of the interactive +rebase are applied. + +If you want to strictly do an interactive rebase of the commits on the +feature branch ignoring what is on `master`, then reference the commit you +checked out from -- put another way, reference the commit before the first +commit on this branch. + +``` +$ git rebase -i ~ +``` + +The tilde (`~`) will go back one commit from the specified commit sha. + +See `man git-rebase` for more details.