Friday, October 16, 2015

Git Rebase for OpenDaylight/Gerrit

I hate merge conflicts, and luckily so far I did not have to do a git rebase for gerrit in OpenDaylight. However, this time I had to. So here are the steps I followed.

pradeeban@llovizna:~/OpenDaylight/distribution$ git-review -d  28471
Creating a git remote called "gerrit" that maps to:
Downloading refs/changes/71/28471/1 from gerrit
Switched to branch "review/pradeeban_kathiravelu/28471"

pradeeban@llovizna:~/OpenDaylight/distribution$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: Add messaging4transport to integration
Using index info to reconstruct a base tree...
M    features/index/pom.xml
M    features/index/src/main/resources/features.xml
M    features/test/src/main/resources/features.xml
M    pom.xml
Falling back to patching base and 3-way merge...
Auto-merging pom.xml
CONFLICT (content): Merge conflict in pom.xml
Auto-merging features/test/src/main/resources/features.xml
CONFLICT (content): Merge conflict in features/test/src/main/resources/features.xml
Auto-merging features/index/src/main/resources/features.xml
CONFLICT (content): Merge conflict in features/index/src/main/resources/features.xml
Auto-merging features/index/pom.xml
CONFLICT (content): Merge conflict in features/index/pom.xml
Failed to merge in the changes.
Patch failed at 0001 Add messaging4transport to integration
The copy of the patch that failed is found in:

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

pradeeban@llovizna:~/OpenDaylight/distribution$ git status
rebase in progress; onto b524a56
You are currently rebasing branch 'review/pradeeban_kathiravelu/28471' on 'b524a56'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Unmerged paths:
  (use "git reset HEAD ..." to unstage)
  (use "git add ..." to mark resolution)

    both modified:      features/index/pom.xml
    both modified:      features/index/src/main/resources/features.xml
    both modified:      features/test/src/main/resources/features.xml
    both modified:      pom.xml

no changes added to commit (use "git add" and/or "git commit -a")

Modify the offending files, the files that are marked as 'both modified'.

Add the modified files.
pradeeban@llovizna:~/OpenDaylight/distribution$ git add features/index/pom.xml features/index/src/main/resources/features.xml features/test/src/main/resources/features.xml pom.xml

pradeeban@llovizna:~/OpenDaylight/distribution$ git rebase --continue
Applying: Add messaging4transport to integration

pradeeban@llovizna:~/OpenDaylight/distribution$ git status
On branch review/pradeeban_kathiravelu/28471
nothing to commit, working directory clean

To amend or modify the commit message,
pradeeban@llovizna:~/OpenDaylight/distribution$ git commit --amend -s

Finally submitting the changes to gerrit,
pradeeban@llovizna:~/OpenDaylight/distribution$ git review
Your change was committed before the commit hook was installed.
Amending the commit to add a gerrit change id.
remote: Processing changes: updated: 1, refs: 1, done   
remote: Updated Changes:
remote: Adding messaging4transport features.
To ssh://
 * [new branch]      HEAD -> refs/publish/master/28471

No comments:

Post a Comment

You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.