1

After doing several changes to my project (deleting files, adding new ones, modifying code..etc), committed my local changes to Github, and everything went fine. Then I tried to do a merge from my branch to MASTER. I received an error that c:/.. can't be written, access denied after that half or more of the project that I had there disappeared.

Why did it delete my files?

How should I merge my changes?

Dev
  • 2,250
  • 22
  • 45

1 Answers1

1

How to find your files

First check if the merge is really over. Try

git merge --abort

Are your files already here? Good! If not, follow the next instruction.

# this shows a graph of commits,
# you will be able to see the commit in master before merge
# save it's sha1 (number)
git log --oneline --graph --decorate --all

git checkout <sha1-of-commit-in-master-before-merge>

# also you can check the last commit in another merged branch just before the branch (with the same command).
git checkout <sha1-of-commit-in-dev-branch>

Check if your files are present in both branches (they should be).

If that is so, you can do the following to return your master branch to the state before merge:

git checkout master
git reset --hard <sha1-of-commit-in-master-before-merge>

Why did it delete your files

There might have been a merge conflict. No idea what it actually was.

How to merge

Here's a good instruction. How to resolve merge conflicts in Git?

Community
  • 1
  • 1
Nick Volynkin
  • 11,882
  • 6
  • 39
  • 62
  • it did not execute the merge to the master, so the master is untouched, – János Csizmadia May 23 '15 at 17:02
  • I understood it so that you were merging to master. Did you checkout to master and run `git merge dev-branch` or checkout to dev-branch and `git merge master`? – Nick Volynkin May 23 '15 at 17:05
  • in the end i managed to merge to master from the webpage of github... but it should have worked anyway :/ i was not using cmd,i did it from VS2013, build in stuff – János Csizmadia May 23 '15 at 17:16