Rebasing with unwanted untracked files. Error merging

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Rebasing with unwanted untracked files. Error merging



I've come across this problem a few times and I have not been able to find an answer yet. Apologies if it turns out to be a duplicate.



Suppose I have the three following commits:
A -- B -- C
(In each commit new files were added).



At some point I want to edit commit A, so I rebase -i and mark A for edit. Unfortunately, I use Sublime as my editor and I mistakenly save one of the files that were committed in C (say file.cpp) while I am editing A. Upon doing git status now there is an untracked file, as expected.


rebase -i


git status



Now once I have made the edits to A that I wanted, I forget about the untracked file and I do git rebase --continue. Upon reaching commit C, I get the error


git rebase --continue


error: The following untracked working tree files would be overwritten by merge:
file.cpp



What should I do at this point? I've tried git stash followed by git rebase --continue, but now I end up with A -- B commits instead of A -- B -- C.


git stash


git rebase --continue



Thanks.





If you run git status at that point, the output should include what Git commands you can run to accept either version of the file.
– Rory O'Kane
yesterday




git status




1 Answer
1



Upon finding such a file, you're left before the new commit is applied. git stash does nothing, because the only thing left is that untracked file.


git stash



You can then git add file.cpp, git stash, git rebase --continue, git stash pop and all will be fine. Just tested with 2.18.


git add file.cpp


git stash


git rebase --continue


git stash pop






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

F14,DaMh
CV4nXL,aPeRvE3sqJqu0jrMhJKRPC3LtsHm,yv6PHb2pR61,P2sGeTuY,PeK,2eN qO9Uc

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

Using generate_series in ecto and passing a value