Remove Files completely from git repository along with its history

前端 未结 3 1276
天命终不由人
天命终不由人 2020-12-12 17:25

I have uploaded a font file that I don\'t have the rights to distribute to git hub several updates ago.

I have a relatively inactive repository and I have the ability

相关标签:
3条回答
  • 2020-12-12 17:51

    I was trying to : Removing sensitive data and history from a repository and ,

    While trying above solution. I found this youtube video, It worked form me : With the reference of the video :

    Command : We need to run this command form git root directory and user relative path of the file in the following command.

    $ git filter-branch --index-filter 'git rm --cache --ignore-unmatch /root-app/props/password.properties' HEAD
    

    Output :

    $ git filter-branch --index-filter 'git rm --cache --ignore-unmatch ./root-app/props/password.properties' HEAD
    Rewrite 7243bb0ad4f3aca3a35e2b5ca86926856e77b666 (14860/14864) (1011 seconds passed, remaining 0 predicted) rm 'root-app/props/password.properties'
    Rewrite 36c00b1203edf35321c0a0204e2fcb6341a5436d (14860/14864) (1011 seconds passed, remaining 0 predicted) rm 'root-app/props/password.properties'
    Rewrite d6bf5d98ec548113f47b9dc7b6dcecf357fdf8db (14860/14864) (1011 seconds passed, remaining 0 predicted) rm 'root-app/props/password.properties'
    

    I hope it will work for others as well.

    0 讨论(0)
  • 2020-12-12 17:52

    In that case you could to use Git Filter Branch command with --tree-filter option.

    syntax is git filter-branch --tree-filter <command> ...

    git filter-branch --tree-filter 'rm -f Resources\Video\%font%.ttf' -- --all
    

    Explanation about the command:

    < command >: Specify any shell command.

    --tree-filter: Git will check each commit out into working directory, run your command, and re-commit.

    --all: Filter all commits in all branches.

    Note: Kindly check the path for your file as I'm not sure for the file path

    Hope this help you !!!

    0 讨论(0)
  • 2020-12-12 17:59

    git filter-branch --index-filter 'git rm --cached --ignore-unmatch Resources\Video\%font%.ttf' HEAD can be much (up to 100x) faster than --tree-filter because it only updates git history and not the working directory.

    ref: What is the difference between "--tree-filter" and "--index-filter" in the "git filter-branch"?
    ref: https://git-scm.com/docs/git-filter-branch

    0 讨论(0)
提交回复
热议问题