I guess I have tried almost all of the solutions available on StackOverflow but could not have my problem solved at all. So maybe someone can help me with this one.
I have a branch that needs to be rebased onto master since there is a change in master. Basically, one of the header files has been deleted and some of its contents moved to another unit (split between a new header/spurce file). The job seems pretty clean – just rebase my branch onto remote master:
git rebase origin/master
This however, creates the main issue – one file in master has been deleted, and I still have it in my branch. Here is the output:
First, rewinding head to replay your work on top of it…
Applying: checkin name…
Usind index info to reconstruct a base tree…
A filename1
M filename2
M filename3
.
.
.
waring: squelched 60 whitespace errors
warninf: 65 lines add whitespace errors
Falling back to patching base and 3-way merge …
Auto-merging file1
Auto-merging file2
Auto-merging file3
Auto-merging file4
CONFLICT (modify/delete): fileheader1.h deleted in HEAD and modified in … Version … of fileheader1.h left int tree.
Failed to merge in the changes.
Patch failed at 0001 …
The copy of the patch failed is found in:
/home/wsluser/tempo/test/Engine/.git/rebase-apply/patch
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”.
So in order to resolve this conflict, I did the following:
git rm fileheader1.h
And the resulting output was:
fileheader1.h needs merge rm ‘fileheader1.h’
The file is gone from the folder; all seem happy, but there is another issue:
git rebase –continue
shows another conflict:
Applying: ……. .. .. Using index info to reconstruct a base tree … M .vscode/settings.json Failed to merge in the changes. Patch failed at 0004 …
which I resolved manually and marked it as done:
git add .vscode/settings.json
Then:
git rebase –continue
And finally, it seems all was fine:
Applying …
Then the final push with:
git push –force origin branchname
And here comes the fun part:
error: src refspec branchname does not match any. error: failed to push some refs to ‘git@…../reponame.git’
My understanding of this message is that it shall appear when one tries to commit/push changes to a branch that does not exist. However, in this case, it is not the case; the branch exists and is very real. Can someone explain/suggest a solution to this problem. I am really pulling the last hair from my head. Thanks a lot in advance!
JJ Moore is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.