Skip to content

skrysmanski/rebase-training

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rebase Training Repo

This Git repository gives you an example where you can train/experiment with Git's rebasing feature.

You can train two things here:

  1. Rebase branch rebase/feature/multiply onto rebase/master.
  2. Rebase and squash branch rebase/feature/multiply onto rebase/master (using interactive rebasing).

In both cases, there will (should) be a merge conflict that you need to resolve.

Getting Started

Follow these instructions to get the repository into a state where you can train:

$ cd <an-empty-dir>
$ git clone -b rebase/master https://github.com/skrysmanski/rebase-training.git .
$ git checkout --track origin/rebase/feature/multiply

Note: If something went wrong, I recommend that you delete the whole directory and re-clone the repository before you try again.

Rebase (without Squash) - in Sourcetree

  1. Open the "Log / History" tab
  2. Checkout source branch (rebase/feature/multiply)
  3. Right-click head of target branch (rebase/master) and select "Rebase..."
  4. Resolve conflict via the "File Status" tab (Right-click on Program.cs and chose "Resolve Conflict")
  5. In the menu choose "Action" -> "Continue Rebase"

Rebase Interactively (with Squash) - in Sourcetree

Interactive rebasing allows you to squash, delete and reorder commits before rebasing them onto a different branch.

Unfortunately, Sourcetree contains an ancient bug; so this feature doesn't fully work.

My current workaround: First do a regular rebase, then do the interactive rebase.

  1. Rebase source branch (rebase/feature/multiply) on target branch (rebase/master)
  2. Open the "Log / History" tab
  3. Right-click the parent of oldest commit you want to rebase interactively (here 5c3d0ea) and select "Rebase children of xxx interactively..."
  4. Modify the commits as desired (check out this video for all the options)

Pushing Changes - in Sourcetree

Once you're done you (probably) need to push your changes back to origin. Normally Git doesn't allow you to push these kind of changes.

Instead you need to "force push" them; ideally by using --force-with-lease instead of --force. You can read on the differences between those two in this article.

To be able to do a "force push" with Sourcetree, this needs to be enabled in the options.

In the menu, go to "Tools" -> "Options" -> "Git" and check "Enable Force Push". Make sure to also check "Use Safe Force Push".

Then you can select "Force Push" in "Push" dialog. (No matter the name, this will automatically use --force-with-lease instead of --force when "Use Safe Force Push" is enabled in the options.)

About

Repo for training Git rebasing

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages