2012-05-13 44 views
0

我遵循這個http://help.github.com/remove-sensitive-data/git的歷史他人保持文件中刪除

但還是有些文件難以清除的,我只需要保持混帳/lib/request.js/lib/response.js://github.com/visionmedia/express.git,別人都應該去掉。

在那篇文章中,我需要告訴要刪除的文件,例如在Rake文件

git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' --prune-empty -- --all

,但我要的是告訴保留哪個文件。

我怎樣才能做到這一點?

回答

0

你確定你不應該創建一個全新的存儲庫,並開始複製這兩個文件嗎?

$ mkdir my_repo 
$ cd my_repo/ 
$ git init 
Initialized empty Git repository in /Users/annelicuss/my_repo/.git/ 
$ wget https://raw.github.com/visionmedia/express/master/lib/request.js 
--2012-05-13 20:38:08-- https://raw.github.com/visionmedia/express/master/lib/request.js 
Resolving raw.github.com... 207.97.227.243 
Connecting to raw.github.com|207.97.227.243|:443... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 8878 (8.7K) [text/plain] 
Saving to: `request.js' 

100%[======================================>] 8,878  --.-K/s in 0s  

2012-05-13 20:38:10 (242 MB/s) - `request.js' saved [8878/8878] 

$ wget https://raw.github.com/visionmedia/express/master/lib/response.js 
--2012-05-13 20:38:16-- https://raw.github.com/visionmedia/express/master/lib/response.js 
Resolving raw.github.com... 207.97.227.243 
Connecting to raw.github.com|207.97.227.243|:443... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 15276 (15K) [text/plain] 
Saving to: `response.js' 

100%[=======================================================================================================>] 15,276  --.-K/s in 0s  

2012-05-13 20:38:17 (280 MB/s) - `response.js' saved [15276/15276] 

$ ls 
request.js response.js 
$ git add * 
$ git commit -m 'Add request, response from Express.' 
[master (root-commit) be4a6d9] Add request, response from Express. 
2 files changed, 1059 insertions(+), 0 deletions(-) 
create mode 100644 request.js 
create mode 100644 response.js 
$ git log 
commit be4a6d9c82cb48b61f662e1e83a9f696a6685883 
Author: Arlen Cuss <[email protected]> 
Date: Sun May 13 20:38:37 2012 +1000 

    Add request, response from Express. 
$ 

請注意,即使這可能不會做你想要的; request.jsresponse.js都取決於,例如, util.js在同一目錄中找到。您可能需要將Express作爲項目的依賴項添加。

+0

https://github.com/kissjs/kick.js/blob/master/lib/request.js我需要導入這個文件作爲我的框架的一部分,但我想保持尊重這些貢獻者的歷史,什麼我做的很愚蠢。 –

+0

@桂林桂林:我不認爲試圖保留改變歷史將會真的做任何事情來表現尊重,它會讓你的工作變得更加困難! – Ashe