简体   繁体   中英

Files missing in Git repository

  • I made an empty private repository called "clonedRepo" .

  • Then I cloned the empty repository locally on my machine under the folder htdocs.

  • Then I dragged a folder called "codebase" that had all the code under the cloned empty repo "clonedRepo".

  • Then I used the Github app for Mac OS X to commit and push all the code under the folder "codebase" to "clonedRepo" but the commit failed because a couple of video files were too large which is fair enough.

  • I clicked the undo commit button.

  • But all of a sudden all the files under "codebase" were gone. The directories remain but the files are gone.

  • I tried "git stash list" for this local repo in the terminal but that just returns the default command prompt.

I didn't have backup of this code and its really important to me because I've been working on this since weeks but making it again from scratch will be time-consuming and mundane. Any idea how I could get it back? I didn't delete the local cloned repo or anything inside it. The local repo displays itself as being worth 302 MB but contains visible stuff worth only 46KB. Please help.

First of all I would like to thank @bitoiu , @Fredric & @eckes for their help.

  • So basically when I added my codebase to an empty repository and committed, the commit couldn't be pushed because a video file in the codebase was larger than 100MB. On pressing "Undo the commit" I believed I lost all the codebase.

  • But actually what happened was it moved to a hidden .git folder
    within the repository.

  • To show hidden files under your repository, see this link : http://ianlunn.co.uk/articles/quickly-showhide-hidden-files-mac-os-x-mavericks/

  • Then type git reflog to get present and past hash codes of the HEAD.

  • Then type git reset --hard <hash code of the commit that introduced the files> to populate all the missing files under your
    repository.More info about git reset and on the use of --hard can be found here : Whats the difference between git reset --mixed, --soft, and --hard? .

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