您能从大量的Git错误中恢复吗?

时间:2018-10-26 06:30:08

标签: git github atlassian-sourcetree

我不确定自己做了什么,但是我在Git中失去了一个星期的工作。我以为我可以从错误中恢复过来,但是我所做的每一件事只会使情况变得更糟。出现推送错误,我尝试返回上一个指针。现在,我的仓库几乎无法识别。我认为总是有可能在Git中恢复您的工作。当我查看每个指针时,我什至看不到文件。 git可以直接删除您的工作吗?如果不是,我需要采取什么步骤来恢复?我可以提供什么信息来帮助人们帮助我?我正在使用Atlassian源代码树,但也可以使用命令行。

$ git reflog
0c5aa71 (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: reset: moving to                                                        0c5aa71c2f25ab704bd5d726ba1f4d8685877680
c472404 HEAD@{1}: reset: moving to c4724042850c29427171c02f72ae754d3fe00254
c472404 HEAD@{2}: checkout: moving from master to master
c472404 HEAD@{3}: checkout: moving from master to master
c472404 HEAD@{4}: checkout: moving from master to master
c472404 HEAD@{5}: checkout: moving from master to master
c472404 HEAD@{6}: reset: moving to c4724042850c29427171c02f72ae754d3fe00254
bca4b8f HEAD@{7}: revert: Revert "A bunch of random work"
c472404 HEAD@{8}: commit: A bunch of random work
0c5aa71 (HEAD -> master, origin/master, origin/HEAD) HEAD@{9}: commit: New slide                                                        format
e7726ac HEAD@{10}: commit: Updates after moving active files to public folder.
2821d93 HEAD@{11}: commit: Initial Commit
e500340 HEAD@{12}: clone: from https://github.com/MassStreetAnalytics/data-wareh                                                       ouse-projects-source-material.git

git checkout c472404
error: The following untracked working tree files would be overwritten
by checkout:
        Course Videos and Section Specific Slides/02 Data Warehouse Overview/
          0205 What technolgy do you need/0205 What technology do you need.pptx
Please move or remove them before you switch branches.
error: The following untracked working tree files would be removed by checkout:
        01 Introduction To The Course/01 Instructor Introduction/
          01 data-warehouse-projects.pptx
Please move or remove them before you switch branches.
Aborting

1 个答案:

答案 0 :(得分:1)

我将发表评论作为快速解答。

如果您在尝试执行签出(或合并或拉取,或使用回购中的文件更改工作树的任何操作)时与本地未提交的工作树更改发生冲突,则git停止,因为它不知道是否会被覆盖的工作对您来说很有价值。

您可以简单地删除有冲突的文件,或者,如果不确定,可以将它们移到不相关的位置以供以后检查。然后,可以继续进行任意提交的检出而不会出现任何问题。

此后,您可以手动应用实际上要保留的编辑内容,例如使用可以处理目录的比较/合并工具。