2017-07-28 73 views
0

你好,我真的有一个奇怪的问题。删除源文件GitHub合并NetBeams

我对所有这些GitHub的东西都很陌生,所以我尝试了一些东西。 基本上发生的事情是,我在Netbeams中有一个项目,并想在我的GitHub上发布它。所以我在Github上创建了存储库,并想向它添加文件。

因此,我进入了Netbeams和Initialized Git Repository。 之后,我进入Git-> Commit 然后我试图推送所有的东西,所以远程 - >推 不知道什么可能出错,我无意识地点击了所有分支的东西,就像有一些东西 - > master或sometig像那样,我现在真的不知道。

但事情是,它失败了。所以我不知何故,做一个拉是个好主意,不知道为什么。这也是它出错的地方。点击所有的东西,它结束了,有一个窗口问我是否要重新组合/合并。我点击了Rebase。然后另一个窗口弹出,告诉我关于结帐冲突的一些信息,所以我点击Revert,突然我的文件都消失了。

我设法重新创建了这个。基本上它发生在我有一个项目时,我从GitHub的空项目中拉出来。有什么办法让我的文件恢复吗?

编辑:从控制台输出

4b83b06 (HEAD -> master, origin/master) [email protected]{0}: pull --no-rebase --progress origin: Fast-forward 
    d47acf2 [email protected]{1}: 
    4b83b06 (HEAD -> master, origin/master) [email protected]{2}: commit: Wa 
    d47acf2 [email protected]{3}: checkout: moving from HEAD to master 
    d47acf2 [email protected]{4}: checkout: moving from master to origin/master 
    d47acf2 [email protected]{5}: rebase finished: returning to refs/heads/master 
    d47acf2 [email protected]{6}: checkout: moving from master to d47acf26594fc3d07b7709ff38a56284267ab993 
    330a8a3 [email protected]{7}: commit (initial): 

Git的居留制:

$ git status 
On branch master 
Your branch is up-to-date with 'origin/master'. 
Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 

     modified: nbproject/private/private.xml 

Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

     nbproject/project.properties 

no changes added to commit (use "git add" and/or "git commit -a") 

的chceckout消息:的

$ git checkout 330a8a3 
error: Your local changes to the following files would be overwritten by checkout: 
     nbproject/private/private.xml 
Please commit your changes or stash them before you switch branches. 
error: The following untracked working tree files would be overwritten by checkout: 
     nbproject/project.properties 
Please move or remove them before you switch branches. 
Aborting 
+0

打开一个终端,并键入'git reflog'。然后'git checkout'之前的提交散列之前。rebasease。 – merlin2011

+0

是否有可能在Windows上? –

+0

Git运行在Windows上,所以它的所有命令也可以在Windows上运行。我会在Windows上推荐'git-bash'。 – merlin2011

回答

0

为了让您的文件备份,他们必须一直一部分在你执行rebase之前的“commit”。 要解决,当你试图签是第一次提交你得到的消息:你需要你的藏匿工作树改变

$ git checkout 330a8a3 
error: Your local changes to the following files would be overwritten by checkout: 
nbproject/private/private.xml 
Please commit your changes or stash them before you switch branches. 
error: The following untracked working tree files would be overwritten by checkout: 
nbproject/project.properties 
Please move or remove them before you switch branches. 
Aborting 

。 git阻止你检出之前的提交,因为文件nbproject/private/private.xml已在工作树中更改,并检出该提交会丢失最近的更改。您应该运行git stash,这将保存您当前的工作树文件。然后,您可以再次运行该结帐命令,git checkout 330a8a3应完成而不会出错。现在你应该能够看到你的原始文件(至少你所有提交到版本库的文件)

此时,我会将想要的文件复制到其他地方保存。如果你想保留您在该private.xml文件做了修改,运行以下命令:。 git checkout master git stash apply 这将让您查看最近一次提交关于master,然后在“负荷”更改以前保存的使用git stash

+0

我爱你!我不得不从那里删除一些文件,但它们并不重要,我把它们收回了!非常感谢你做的这些。我所做的就是删除每个文件,比如private.xml和其他文件,然后执行git chceckout 330a8a3并且它能够工作! –

+0

感谢您的反馈,将我的答案标记为解决方案,我很高兴您的问题得到解决!我建议你阅读'stash'命令的文档,因为使用'git'时它是绝对重要的。 https://git-scm.com/docs/git-stash – instantepiphany