开发者

How do I edit the initial commit in a github repository?

I'm working on a repository I forked in which the author took the dirty path and stuffed all his dependencies in the lib/ directory in the initial commit. Normally, if it wasn't the initial commit, I would just do an interactive rebase and delete the entire commit (if that's all he did)开发者_开发问答. However, I have no idea how I would edit/delete the initial commit. Is there a way I can edit the initial commit and remove the lib directory without touching the rest of it?

EDIT

I accidentally stumbled upon the answer here: Can I remove the initial commit from a Git repo? in the selected answer. That's what I get for not searching more thoroughly.


$ git filter-branch --parent-filter \
  'test $GIT_COMMIT = SECOND && echo "" || cat' \
  --tag-name-filter cat -- --all

where SECOND is the SHA-1 of the commit you want to be the new root.

The above assumes that all branches use the same first and second commits. If not, you'll need to generalize the test in the parent filter.

Note that this is a drastic measure: it will rewrite your entire history and keep you from following the author's repo. Also if you've pushed your repo to remotes, you'll need to clobber those with git push -f.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜