Frage

So basically, here's what happened with me:

  1. I was working on a branch, let's call it 'dev'
  2. I didn't yet stage or commit my changes. However, I needed to test something quick for someone in a new branch.
  3. So I executed git checkout -b testbranch dev on the command line
  4. This created a branch called 'testbranch' off of 'dev' and checked out that branch
  5. However, all the files I had modified in my 'dev' branch (which I didn't stash, stage, and commit prior to executing point 3) got listed in the terminal with a M next to them to indicate modified.
  6. I worked on the testbranch and once the work was complete, staged and committed my changes and switched back to 'dev' branch.
  7. Unfortunately, it looks like that all the changes I had made in the dev branch prior to creating/switching the testbranch got lost when I looked at the project in xcode.

So my question is: Is there any way for me to recover the files? Note that my terminal session is still running and I will keep it running until I either get a solution to recover my changes or I find out that those changes are lost forever. HELP!!!!

Thanks,

-Vivek Kinra

War es hilfreich?

Lösung

Your changes are not lost.

The first time they were there on the new testbranch after step 3, it was because the changes weren't committed to branch dev.

Next, when you committed those to the testbranch, the commit got associated with testbranch, and thus won't be available on dev branch before you explicitly tell git to do so.

In this case, it seems to me that you are fine with all the code in testbranch to be brought into dev branch, so you can do a simple merge.

git checkout dev
git merge testbranch

This will bring all your changes to dev branch.

Andere Tipps

I think your previous work in dev was mixed with your test work in testbanch.

I'm not sure how much test work you have done in testbranch. If you haven't done a lot of work, you could:

First pick the commit tag in testbranch through git log.

git checkout testbranch
git diff "tag" > /location/out/of/repo

Edit /location/out/of/repo, delete the work you have done for test.

git checkout dev
git apply /location/out/of/repo
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top