I forked a github repo and worked on my github repo.
I have made pull-requests and it was completed.
After that the upstream had some more commits so now I want to rebase, I guess thats what I have to do.
But I'm getting these merge conflicts:
First, rewinding head to replay your work on top of it... Applying: Issue 135 homepage refresh Using index info to reconstruct a base tree... <stdin>:17: trailing whitespace. %h4 warning: 1 line adds whitespace errors. Falling back to patching base and 3-way merge... Auto-merging app/views/layouts/application.html.haml CONFLICT (content): Merge conflict in app/views/layouts/application.html.haml Auto-merging app/views/home/index.html.haml CONFLICT (content): Merge conflict in app/views/home/index.html.haml Auto-merging app/views/home/_group_projects.html.haml CONFLICT (content): Merge conflict in app/views/home/_group_projects.html.haml Failed to merge in the changes. Patch failed at 0001 Issue 135 homepage refresh When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To check out the original branch and stop rebasing run "git rebase --abort".
I don't know how to fix these, please help.
Rebasing is not going to magically remove all merge conflicts. In fact, you may encounter conflicts while rebasing. Sometimes, you will have to repeatedly resolve the same conflict while rebasing. However, merge conflicts happen because multiple changes happen to the same chunk of code simultaneously.
Handling Conflicts When Rebasing When applying commits to a new base state, it is possible that the new base has made changes that are conflicting with the changes you are trying to apply. For example, if on main someone edited the same file and line you did on your branch. The same thing happens when merging.
Rebasing can be a real headache. You have to resolve the merge conflicts and continue rebasing. For example you can use the merge tool (which differs depending on your settings)
git mergetool
Then add your changes and go on
git rebase --continue
Good luck
If you have a lot of commits to rebase, and some part of them are giving conflicts, that really hurts. But I can suggest a less-known approach how to "squash all the conflicts".
First, checkout temp branch and start standard merge
git checkout -b temp git merge origin/master
You will have to resolve conflicts, but only once and only real ones. Then stage all files and finish merge.
git commit -m "Merge branch 'origin/master' into 'temp'"
Then return to your branch (let it be alpha) and start rebase, but with automatical resolving any conflicts.
git checkout alpha git rebase origin/master -X theirs
Branch has been rebased, but project is probably in invalid state. That's OK, we have one final step. We just need to restore project state, so it will be exact as on branch 'temp'. Technically we just need to copy its tree (folder state) via low-level command git commit-tree. Plus merging into current branch just created commit.
git merge --ff $(git commit-tree temp^{tree} -m "Fix after rebase" -p HEAD)
And delete temporary branch
git branch -D temp
That's all. We did a rebase via hidden merge.
Also I wrote a script, so that can be done in a dialog manner, you can find it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With