English 中文(简体)
我如何去掉一个错误地以盖特(复制)为名的大型档案。
原标题:How do I remove a big file wrongly committed in git [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
How to purge a huge file from commits history in Git?

我做了一件 st事。 Imagine说,我投了100MB卷宗。 之后,我看到这一点,删除这一档案并再次作出承诺。 这是删除档案的正常程序。

但现在的副作用是,我的历史是沉重的,因为它拯救了这个庞大的档案(我认为这是为什么如此沉重)。 我只使用当地电梯,因此我不协调任何服务器。

我怎样才能最终消除这一档案,节省磁盘空间?

最佳回答

您可使用<代码>过滤器-branch。 指挥:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch path_to_file" HEAD

You can find more documentation here http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository

问题回答

您的指令是filter-branch。 这使你能够永远从招募中删除档案。 这一博客就如何从存放处删除有问题的档案拥有很大的指导。

您可在David Underhill上拿这一伟大文字,将档案从盖特存放处删除:

#!/bin/bash
set -o errexit

# Author: David Underhill
# Script to permanently delete files/folders from your git repository.  To use 
# it, cd to your repository s root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2

if [ $# -eq 0 ]; then
    exit 0
fi

# make sure we re at the root of git repo
if [ ! -d .git ]; then
    echo "Error: must run this script from the root of a git repository"
    exit 1
fi

# remove all paths passed as arguments from the history of the repo
files=$@
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD

# remove the temporary history git-filter-branch otherwise leaves behind for a long time
rm -rf .git/refs/original/ && git reflog expire --all &&  git gc --aggressive --prune




相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签