0

我按照这个http://help.github.com/remove-sensitive-data/

但仍有一些文件难以删除,我只需要保留/lib/request.js /lib/response.js在 git://github.com/visionmedia/express.git 中,其他文件应该全部删除。

在那篇文章中,我需要告诉要删除哪个文件,例如 Rakefile

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

但我想要的是告诉要保留哪个文件。

我怎样才能做到这一点?

4

1 回答 1

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 <a@unnali.com>
Date:   Sun May 13 20:38:37 2012 +1000

    Add request, response from Express.
$ 

请注意,即使这样也可能无法满足您的要求;两者都request.js依赖response.js于,例如util.js在同一目录中找到。您可能只想添加 Express 作为项目的依赖项。

于 2012-05-13T10:39:33.783 回答