0

I would like to create a test case that solves a rebase conflict, but first I need a way to cause the rebase conflict when doing a git pull --rebase.

Is there a programmatic way of creating a rebase conflict scenario?

The test will be for a GitPython program.

  • By *rebase conflict* do you mean a *merge conflict*, that makes the rebase stop and require you to clean up the mess and run `git rebase --continue`? – torek May 29 '18 at 16:44
  • Yes, I wan't to run into that scenario where you are in the rebase process and need to solve merge conflicts and continue. – Haibrayn González May 29 '18 at 20:43
  • OK, then PapyDanone's answer will do the trick. – torek May 29 '18 at 20:49

1 Answers1

2

To quickly create a rebase conflict, you can do the following:

  1. modify a file, commit and push to the remote repository
  2. make a change to the same file on the same line
  3. amend the last commit with git commit -a --amend -C HEAD. The HEAD commit hash has now changed
  4. run git pull --rebase

You'll end up with a conflict at the line you modified.

To clean up: you may want to git reset --hard origin/[your-branch] after your test to get back to step 1.

PapyDanone
  • 281
  • 1
  • 4