简体   繁体   English

Git存储库中缺少文件

[英]Files missing in Git repository

  • I made an empty private repository called "clonedRepo" . 我创建了一个空的私有存储库,名为“ clonedRepo”。

  • Then I cloned the empty repository locally on my machine under the folder htdocs. 然后,将空的存储库本地复制到我的计算机上的htdocs文件夹下。

  • Then I dragged a folder called "codebase" that had all the code under the cloned empty repo "clonedRepo". 然后,我拖动了一个名为“ codebase”的文件夹,该文件夹中的所有代码都位于克隆的空存储库“ 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. 然后,我使用Mac OS X的Github应用进行提交,并将文件夹“ codebase”下的所有代码推送到“ clonedRepo”,但是提交失败,因为几个视频文件太大,这是足够的。

  • 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. 我在终端中为此本地存储库尝试了“ git stash list”,但这只是返回默认命令提示符。

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. 本地存储库显示自己的大小为302 MB,但包含的可见内容大小仅为46KB。 Please help. 请帮忙。

First of all I would like to thank @bitoiu , @Fredric & @eckes for their help. 首先,我要感谢@bitoiu,@Fredric和@eckes的帮助。

  • 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. 因此,基本上,当我将我的代码库添加到空存储库中并提交时,由于代码库中的视频文件大于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 但是实际上发生了什么事,它移到了一个隐藏的.git文件夹中
    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/ 要在存储库中显示隐藏文件,请参见以下链接: 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. 然后输入git reflog以获取HEAD的当前和过去的哈希码。

  • Then type git reset --hard <hash code of the commit that introduced the files> to populate all the missing files under your 然后键入git reset --hard <hash code of the commit that introduced the files>填充您下的所有丢失文件
    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? git reset--hard的使用的更多信息可以在这里找到: git reset --mixed,-soft和--hard有什么区别? .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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