我似乎已经失去了我的下午的工作在一个新的回购。以下是我所做的:舞台文件,然后远程添加,然后拉 - 我的文件不见了
- 在本地创建了一个新项目并完成了一些工作。
- 创建了一个回购GitHub上
git init
git add src
git remote add origin [email protected]:Synesso/memx.git
git pull origin master
git add .gitignore
git commit -m 'updated ignore'
git push origin master
我的本地回购和github回购只有两个提交。最初的提交(由github在项目创建时作出)和第二次只包含文件.gitignore
。
在步骤4(git add src
)中添加的文件不存在。他们似乎也没有上演。
当你做git pull
时,你会丢失上演的文件吗?我可以以某种方式检索它们吗?
当前状态:
$ git status
# On branch master
nothing to commit (working directory clean)
我inital add
不在引用日志。
$ git reflog
c80135d [email protected]{0}: checkout: moving from 999d128ea4e6969f9eacbceebb5f857f2aa5abb0 to master
999d128 [email protected]{1}: checkout: moving from master to HEAD~1
c80135d [email protected]{2}: checkout: moving from 999d128ea4e6969f9eacbceebb5f857f2aa5abb0 to master
999d128 [email protected]{3}: checkout: moving from master to 999d128ea4e6969f9eacbceebb5f857f2aa5abb0
c80135d [email protected]{4}: commit (amend): updated ignore
28b4f90 [email protected]{5}: commit: updated ignore
999d128 [email protected]{6}: initial pull
history
表明,我添加了src
文件夹,但没有提交它:
223 git init
225 git add src
229 git add project/Build.scala
234 git remote add origin [email protected]:Synesso/memx.git
250 git pull origin master
我知道,如果你尝试用本脏文件获取Git会抱怨。但是,这样做可以消除阶段性文件的拖动效果。这似乎是错误的。
我刚刚测试过这个过程,是的,它销毁了上演的文件。
[email protected]:~/projects$ mkdir x
[email protected]:~/projects$ cd x
[email protected]:~/projects/x$ git init
Initialized empty Git repository in /home/jem/projects/x/.git/
[email protected]:~/projects/x$ echo "hi" > hello.world
[email protected]:~/projects/x$ git add hello.world
[email protected]:~/projects/x$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: hello.world
#
[email protected]:~/projects/x$ ls -asl
total 24
4 drwxrwxr-x 3 jem jem 4096 Apr 28 20:56 .
4 drwxr-xr-x 8 jem jem 4096 Apr 28 20:56 ..
4 drwxrwxr-x 7 jem jem 4096 Apr 28 20:56 .git
12 -rw-rw-r-- 1 jem jem 3 Apr 28 20:56 hello.world
[email protected]:~/projects/x$ git remote add origin [email protected]:Synesso/memx.git
[email protected]:~/projects/x$ git reflog
fatal: bad default revision 'HEAD'
[email protected]:~/projects/x$ git pull origin master
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (7/7), done.
From github.com:Synesso/memx
* branch master -> FETCH_HEAD
[email protected]:~/projects/x$ ls -asl
total 36
4 drwxrwxr-x 3 jem jem 4096 Apr 28 20:53 .
4 drwxr-xr-x 8 jem jem 4096 Apr 28 20:52 ..
4 drwxrwxr-x 8 jem jem 4096 Apr 28 20:53 .git
12 -rw-rw-r-- 1 jem jem 59 Apr 28 20:53 .gitignore
12 -rw-rw-r-- 1 jem jem 9 Apr 28 20:53 README.md
[email protected]:~/projects/x$ git reflog
c80135d [email protected]{0}: initial pull
文件hello.world
被删除时未显示警告。
'git reflog'会显示你的树形修改。但是如果你从未犯过'src'文件... – 2012-04-28 09:58:51
现在'git status'说了什么? – vissi2 2012-04-28 10:40:54