简体   繁体   中英

Files were not listed with git status and got lost after a commit

I lost files from my local repo. by "mistake" after using git. Am trying to understand that mistake and undo it if possible. what I did sequentially is:

git status
git add -A
git commit -m "some message"
git push origin master

The weird part is that I had some new files (since the last commit) that did not get committed and pushed, and now do not exist on my local repo.

Looking more into it, I saw that my git status did not list these files in the first place. These are the files that I lost. Why would that happen ? and is there a way to get them back ?

I have git version 1.8.3.1

If you didn't add the files to git at any point, it's unlikely you can recover them using git. You can see if they are in your repository by this handy "one-liner"

alias gitobjects="git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %
       │ (objectname) %(objectsize) %(rest)' | sed -n 's/^blob //p' | sort --numeric-sort --key=2 | c
       │ ut -c 1-12,41- | numfmt --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest"
gitobjects | grep "myfile"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM