我似乎已經失去了我的下午的工作在一個新的回購。以下是我所做的:舞臺文件,然後遠程添加,然後拉 - 我的文件不見了
- 在本地創建了一個新項目並完成了一些工作。
- 創建了一個回購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