Skip to content

Introduction

What is this tutorial about?

This repository proposes an interactive way to play with git interactive rebase, a powerful feature that can be intimidating.

Pre-requisite

You should be familiar with basic git commands.

It makes little sense to dive into the power-user world if you don't know the basics.

Your Editor

Your editor is your choice.

You can use vi, emacs, or any other. This has no impact on the outcome.

Most activities are designed to be done in a command-line interface, typically your favorite Bash or Zsh. So, console-friendly editors are not an issue.

This being said, we need a common ground for the examples. So, VSCode is a reasonable option.

Through this course content, I will assume you are using VSCode. So, remember to mentally replace references to code or VSCode with your editor of choice.

TIP

On macOS, you need to configure your PATH to include the code command that invokes VSCode from your shell.

This is done from VSCode itself. Just press the Shift + Command + P and in the prompt, search for "install code command in PATH"

VSCode prompt to install code

Git configuration

Your editor

There are two ways to tell Git which editor you prefer to use:

  • define and export GIT_EDITOR shell variable
  • use the Git configuration

Variable

To use the environment variable solution, you just need to run the command:

bash
export GIT_EDITOR="code --wait"

This will tell Git to run VSCode and wait for it to close the edited file before continuing.

Configuration

A simpler solution is to change Git global configuration:

bash
git config --global core.editor "code --wait"

WARNING

Throughout this course, I will assume that you changed the Git configuration to use your editor of choice.

I won't recall each time to configure your editor.