Skip to main content
added 8 characters in body
Source Link
  1. Switch to a new branch (git checkout -b experiment)

    git checkout -b experiment 
  2. Commit the changes

  3. Revert the changes

  4. Merge the branch into master, avoiding a fast-forward so that there will be an actual merge commit.

    git checkout master git merge experiment --no-ff 

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.

In fact it's even possible to omit the undo commit, and instead merge from idea directly without actually including the changes. This would however be confusing, since it will look like the changes were taken into master and only the diffs would show they weren't.

  1. Switch to a new branch (git checkout -b experiment)

  2. Commit the changes

  3. Revert the changes

  4. Merge the branch into master, avoiding a fast-forward so that there will be an actual merge commit.

    git checkout master git merge experiment --no-ff 

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.

In fact it's even possible to omit the undo commit, and instead merge from idea directly without actually including the changes. This would however be confusing, since it will look like the changes were taken into master and only the diffs would show they weren't.

  1. Switch to a new branch

    git checkout -b experiment 
  2. Commit the changes

  3. Revert the changes

  4. Merge the branch into master, avoiding a fast-forward so that there will be an actual merge commit.

    git checkout master git merge experiment --no-ff 

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.

In fact it's even possible to omit the undo commit, and instead merge from idea directly without actually including the changes. This would however be confusing, since it will look like the changes were taken into master and only the diffs would show they weren't.

added 329 characters in body
Source Link
  1. Switch to a new branch

    Switch to a new branch (git checkout -b experiment)

  2. Commit the changes

    Commit the changes

  3. Revert the changes

    Revert the changes

  4. Merge the branch into master, as --no-ff

    Merge the branch into master, avoiding a fast-forward so that there will be an actual merge commit.

    git checkout master git merge experiment --no-ff 

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.

In fact it's even possible to omit the undo commit, and instead merge from idea directly without actually including the changes. This would however be confusing, since it will look like the changes were taken into master and only the diffs would show they weren't.

  1. Switch to a new branch
  2. Commit the changes
  3. Revert the changes
  4. Merge the branch into master, as --no-ff

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.
  1. Switch to a new branch (git checkout -b experiment)

  2. Commit the changes

  3. Revert the changes

  4. Merge the branch into master, avoiding a fast-forward so that there will be an actual merge commit.

    git checkout master git merge experiment --no-ff 

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.

In fact it's even possible to omit the undo commit, and instead merge from idea directly without actually including the changes. This would however be confusing, since it will look like the changes were taken into master and only the diffs would show they weren't.

Source Link

  1. Switch to a new branch
  2. Commit the changes
  3. Revert the changes
  4. Merge the branch into master, as --no-ff

The result will be this history:

... A ── B ──────────── C ── D ... ─master ╲ ╱ idea ── undo ─experiment 

Advantages:

  • The addition and deletion are clearly grouped together, and can still easily be referenced.
  • There is a continuous history skipping the whole experiment, with an empty diff between B and C.
  • There are no unmerged branches to be kept around. The experiment branch can be deleted without losing the commits.