🛠️
Notes
  • README
  • ansible
    • Literal curly braces (raw)
  • bash
    • Case statement
    • Change quote style mid-string
    • Comparing versions
    • Hiding credentials on the command line
    • Directory of script
    • Using find to run a command on multiple files
    • Getting the line number of the nth match
    • Getopts
    • Parsing output with long lines using less
    • Print line at number
    • Remove final newline
    • Reading content between markers
    • Determine if a script was sourced or executed
    • Bash substring
    • Run a function on interrupt or error
    • Reference variable by name
  • chrome
    • Bypassing Chrome's NET::ERR_CERT_INVALID page
  • css
    • box-sizing: border-box
    • The currentColor keyword
    • Wrapper taking up at least 100% height
    • Using margin: auto; for centering
    • Margin-collapse
    • Which unit to use?
    • Hiding elements
  • git
    • Conditional git config includes
    • Viewing the evolution of a line or function
    • Name of current branch
    • Get the path to the repository root
    • Replaying a set of changes on a specific branch
    • Hide file from git diff output
    • Listing untracked files with git status
  • github
    • Setting up GitHub Actions
  • groovy
    • Appending items to a list
  • kubernetes
    • Waiting for a pod to be ready
  • make
    • Passing arguments to make rules
    • Running make in a set of subdirectories
  • npm
    • Update a value in a project's .npmrc
  • podman
    • Target last container
  • rust
    • The match operator
    • Unwrapping a Result
  • tmux
    • New window with prompt
  • tools
    • Running ngrok in the background
    • Using entr to react to file changes
  • typescript
    • Inferring the type of elements in an array
  • vim
    • The command-line window
    • Populate quickfix list with eslint errors
    • Visual increment
    • Opening a list of files in split windows
    • Insert line above matched line
    • Spelling
    • The tabular plugin
    • Populate quickfix list with tsc errors
  • yaml
    • Yaml multiline strings
  • zsh
    • Lazy loading command setup
Powered by GitBook
On this page

Was this helpful?

  1. git

Replaying a set of changes on a specific branch

git rebase --onto somewhere base extension

Take the extension branch, figure out where it diverged from the base branch, and replay these patches in the extension branch as if it was based off the somewhere branch instead.

With a history like this,

c1 - c2 - c3 (master)
      \
        c4 - c5 - c6 (server)
              \
                c7 - c8 (client)

running

git rebase --onto master server client

would result in:

          (master)
c1 - c2 - c3 - c7' - c8' (client)
      \
        c4 - c5 - c6 (server)

NB: if the rebase of extension on base would not result in any commit (extension and base pointing to the same commit), no commits will be added onto somewhere.

Say a fix has been developed on the branch fix, and that the changes have been incorporated in the master branch in some manner (merge, cherry-pick, etc). Now we want to backport the fix to a previous point in the history, v1.

(v1)           (master)            (v1)           (master)
c1 - c2 - c3 - c4'                 c1 - c2 - c3 - c5
      \                   OR             \      /
        c4 (fix)                           c4 (fix)

In this case, running

git rebase --onto v1 master fix

will only move fix to v1.

(v1, fix)           (master)
c1 - c2 - c3 - c4'

The changes in c4 will not be replayed on top of c1, because replaying fix on master would not include c4, since it's already part of master.

Source:

PreviousGet the path to the repository rootNextHide file from git diff output

Last updated 3 years ago

Was this helpful?

Pro Git
experience
learning the hard way