After repeating your steps my git status shows me
# On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: newfile1 # new file: newfile2 #
This mean, that you did something else to your repository, that you didn't considered important nor potentially harmful.
And now to your actual question: Yes, you might be able to do it.
- First do a complete backup of your
.git directory Create a file all-objects.sh with this script (source: https://gist.github.com/ctindall/4588884)
#!/bin/sh set -e cd "$(git rev-parse --show-cdup)" # Find all the objects that are in packs: if [ "$(ls -A .git/objects/pack)" ] then for p in .git/objects/pack/pack-*.idx do git show-index < $p | cut -f 2 -d ' ' done fi # And now find all loose objects: find .git/objects/ | egrep '[0-9a-f]{38}$' | \ sed -r 's,^.*([0-9a-f][0-9a-f])/([0-9a-f]{38}),\1\2,'
- If you on Linux/Mac: make it executable:
chmod a+x all-objects.sh - Remember some small part of the missing data (string, method name, ...)
Find this part changing grep parameter in the following script
for rev in $(./s.sh) ; do C=$(git show $rev | grep <METHOD_NAME_OR_SOMETHING_FROM_MISSING_FILE> ) if [[ "$C" != "" ]] ; then echo $rev echo $C fi done
git statusdo the new files show up aschanges to be committed?git checkout -b masterseems suspect as there should already be amasterbranch. Maybe there is a typo on this line and maybe there is a branch that is closely named tomasterthat hasnewfile1andnewfile2. What doesgit branchshow?