Search code examples
gitgithub

Switched branch without commiting changes, what do I do now?


I'm making my edits on a branch while my partner is working on the main. I switched branch to check on their latest push but I didn't commit my change before changing to the main branch. I didn't know it was gonna mess things up for me when I returned to mine. Now I'm stuck with this:

GitHub page:

Github page

When I hit restore:

When I hit restore

error: Could not write index
FullHarvest_Daph (MajorPush-1)/Packages/manifest.json: needs merge
FullHarvest_Daph (MajorPush-1)/Packages/packages-lock.json: needs merge
The stash entry is kept in case you need it again.

I can see that my changes are still there, but how do I restore it?

I've only tried hitting restore and ran into the above error. I directly edited everything from my latest commit. Was told my burst package was removed when I went back to my in-progress-file so I ended up CLOSING it--not sure if I should have. Now I can no longer open the file.

I also selected "leave changes in my branch" before changing to main, and when switching back to my branch I selected "bring change over". But the changes I see stashed so far are accurate to the changes I make.

I don't know how to proceed. I'm afraid of damaging things further. Do I try committing whatever there is to commit - then restore to stash?

I am new to game development, coding, and GitHub, so please have patience with me.


Solution

  • The easiest and safest way to deal with any course control issue like this is to copy your local files to a new directory, then wipe the version controlled working copy (ie your local stuff), check out fresh and then then copy your changes over the top as if you'd just edited them.

    Over the years I have found this works to solve any and every issue with your SCM.