Git: how to use rebase with theirs strategy

Basically, I just want to (re)set the parent (let’s say to commit A) of a specific commit (commit B) which is the root commit of some branch x. It is suggested here in one of the answers that I can do that via grafts. I will try that later, maybe it’s the better way.

However, before reading this, I thought that this should be possible via rebase. But because the parent commit A differs a bit from B and I just want to stay the whole branch x the way it is, just with setting a parent to its root commit B, I thought I might use the theirs strategy — which doesn’t seem to exist. I have stumbled upon this earlier (and thought it was a bug or in my Git installation) and always just worked-around by switching branches and using the ours strategy. However, with rebase, I am forced to use the theirs strategy in this case.

  • Error: Unable to access jarfile bfg.jar - BFG
  • Bitbucket + XCode 4.2 + Git
  • Error in running 'git apply'
  • Avoiding to hardcode server configuration
  • Troubles sharing my project from IntelliJ to GitHub (IntelliJ-GitHub permission denied, error= 13)
  • Git Clone Vs Git Create Repository
  • My command looks like:

    git rebase -s theirs --onto A --root x x--rebased

  • Apply gitignore on an existing repository already tracking large number of files
  • How do I debug a large git commit?
  • git inspect time at which commit was pushed
  • “Reverse-merge” a branch
  • GIT post-receive checkout without root folder
  • Git: Best strategy to create repos
  • One Solution collect form web for “Git: how to use rebase with theirs strategy”

    rebase isn’t designed for what you want to do. The other poster was correct; what you want to do is set up a graft to attach B to A, then run git filter-branch to bake it into the commits. An example of this exact use case can be found in the git filter-branch manpage.

    Git Baby is a git and github fan, let's start git clone.