2012-03-15 54 views
0

所以我是在Ruby on Rails中工作的新手。我承諾所有的東西,並把它推到混帳,然後我的項目恢復到舊版本。我的最新版本安全地存儲在git上,但現在我的計算機上的所有原始文件都消失了,並替換爲舊版本。這是怎麼回事?推到Git,一切都消失了?

編輯:更多細節:

git status 
# On branch 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: .DS_Store 
# modified: app/.DS_Store 
# modified: app/assets/stylesheets/static_pages.css.scss 
# modified: app/views/static_pages/home.html.erb 
# 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# 
# app/assets/.DS_Store 
# app/assets/images/.DS_Store 
# public/chat.png 
# public/groups.png 
# public/join-free.png 
# public/login-button.png 
# public/meetups.png 
# public/people.png 
# public/posts.png 
# public/profile.png 
# public/stream.png 
# public/streambaby.png 
# public/streamblue.png 
# public/streamlime.png 
no changes added to commit (use "git add" and/or "git commit -a") 
Lasers-MacBook-Pro:meetumea lasernite$ git add . 
Lasers-MacBook-Pro:meetumea lasernite$ git commit -m "home page basic" 
[master 49921d4] home page basic 
Committer: Laser Nite <[email protected]> 
Your name and email address were configured automatically based 
on your username and hostname. Please check that they are accurate. 
You can suppress this message by setting them explicitly: 

    git config --global user.name "Your Name" 
    git config --global user.email [email protected] 

After doing this, you may fix the identity used for this commit with: 

    git commit --amend --reset-author 

18 files changed, 144 insertions(+), 9 deletions(-) 
create mode 100644 app/assets/.DS_Store 
create mode 100644 app/assets/images/.DS_Store 
rewrite app/assets/stylesheets/static_pages.css.scss (100%) 
rewrite app/views/static_pages/home.html.erb (100%) 
create mode 100644 public/chat.png 
create mode 100644 public/groups.png 
create mode 100644 public/join-free.png 
create mode 100644 public/login-button.png 
create mode 100644 public/meetups.png 
create mode 100644 public/people.png 
create mode 100644 public/posts.png 
create mode 100644 public/profile.png 
create mode 100644 public/stream.png 
create mode 100644 public/streambaby.png 
create mode 100644 public/streamblue.png 
create mode 100644 public/streamlime.png 
Lasers-MacBook-Pro:meetumea lasernite$ git branch 
* master 
    work 
Lasers-MacBook-Pro:meetumea lasernite$ git push 
Counting objects: 39, done. 
Delta compression using up to 8 threads. 
Compressing objects: 100% (27/27), done. 
Writing objects: 100% (27/27), 60.94 KiB, done. 
Total 27 (delta 11), reused 0 (delta 0) 
To [email protected]:lasernite/meetumea.git 
    a78c8f0..49921d4 master -> master 
Lasers-MacBook-Pro:meetumea lasernite$ git status 
# On branch master 
nothing to commit (working directory clean) 
Lasers-MacBook-Pro:meetumea lasernite$ git co work 
Switched to branch 'work' 
Lasers-MacBook-Pro:meetumea lasernite$ git status 
# On branch work 
nothing to commit (working directory clean) 

然後我發現我的所有文件都是舊版本,我所有的新形象從公衆文件夾不見了。我只是運行rm -rf meetumea,然後從github克隆我的項目,這樣問題就解決了。不過,我仍然想知道發生了什麼。

+2

不知道發生了什麼,需要更多的細節。我會試着從Github上拉,如果這不起作用,你可能不得不恢復到你當地回購的過去狀態。 – 2012-03-15 02:09:52

+0

你跑的確切命令是什麼? – 2012-03-15 02:15:58

+0

編輯 - 添加了通過終端的所有內容。 – Laser 2012-03-15 02:20:59

回答

4

在我看來,就像你在你的問題中粘貼的東西之前創建了一個名爲「work」的分支。然後,您對主分支(下面的'newcommit')進行了一些更改並推送了它。然後檢出在新提交之前分支的「工作」分支。這意味着它不會包含新的提交。如果您要再次簽出主人,您會再次看到您的更改。

newcommit (master) 
    | 
    | 
    |     othercommit (work) 
    |     /
basecommit------------' 

因此,如果您簽出'工作',那麼newcommit不會在該分支上。或可能從未有過的「工作」分支任何新的提交,在這種情況下「工作」仍然指向basecommit:如果你籤「工作」你回來之前newcommit存在

newcommit (master) 
    | 
    | 
    | 
    | 
basecommit (work) 

左右。請記住,git中的分支只是指向提交的指針,當您添加提交時,提交會自動移動(並且標記是不會自動移動的指針)。