我正在尝试这个混帐的东西,我想我搞砸了。所以我在我的电脑里有一个名为Foo的项目。我改变了目录到那个项目。然后,git init,然后git commit到我的github中。它说它没有推送一些ref到服务器,所以我搜索了它,有人说我需要先做一个git pull。好的,所以我在Project Foo的目录中做了一个github服务器的git pull请求。现在,我的项目Foo目录中的所有文件都被删除,只有来自git pull请求的文件存储在我的Project Foo的目录中。git问题!我不小心删除了我的项目文件?
帮助,如何重新获取我的文件?
编辑:这里是终端历史,http://codepad.org/cg9Gi7Ii - 从日志各地哪里消失的文件是点的命令:
$ ls
Models css js utils
README index.html styles
$ git init
Initialized empty Git repository in /Users/MacBoss/Documents/workspace/BlackboardCanvas/.git/
$ git add .
$ git remote add origin [email protected]:dchhetri/Demo-s.git
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:dchhetri/Demo-s.git'
$ git remote add origin [email protected]:dchhetri/Demo-s.git
fatal: remote origin already exists.
$ git push origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:dchhetri/Demo-s.git'
$ git pull failed to push some refs to '[email protected]:dchhetri/Demo-s.git'
fatal: 'failed' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From github.com:dchhetri/Demo-s
* [new branch] master -> origin/master
You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
If you often merge with the same branch, you may want to
use something like the following in your configuration file:
[branch "master"]
remote = <nickname>
merge = <remote-ref>
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
$ git pull failed to push some refs to '[email protected]:dchhetri/Demo-s.git'
fatal: 'failed' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git pull [email protected]:dchhetri/Demo-s.git
From github.com:dchhetri/Demo-s
* branch HEAD -> FETCH_HEAD
$ ls
AStarDemo.jar
除了'git pull'外,你还运行过其他的命令吗? – ctcherry
这就是我做的,git init,然后触摸README,然后git commit,然后git remote origin [email protected]:dchhetri/Demo-s.git,然后git push master,失败时说一些ref没有推到服务器,所以我做了一个git拉,我的文件都没有了。另外我想补充一点,以前我使用rm -r .git来从Foo的项目目录中删除.git文件夹,我不知道是否对Foo中的文件做了什么。 – dchhetri
我添加了终端历史记录,它显示我之前的拉取请求,所有文件都在那里,现在它不是, – dchhetri