How to delete files from git bare remote repository?

余生颓废 提交于 2019-12-05 07:47:16

This is a three step process:

  1. Remove the files from your copy of the repository (either with git rm or by totally purging these files from your history depending on how important it was that these files never be in the repository in the first place)
  2. Push your changes back to the remote repository using git push --force.
  3. Let everyone know that they can re-pull the repository - this will require a git rebase of their work on the last know good commit.

As a last step you may also want to add the .gitignore file to the repository so that when the repository is cloned all the right files get ignored.

See github have a FAQ on this: https://help.github.com/articles/remove-sensitive-data Here are the steps:

  1. Rewrite the tree from local (working) tree.

    $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch Rakefile' \ --prune-empty --tag-name-filter cat -- --all

  2. Force push to remote.

    $ git push origin master --force

  3. Everybody pull from the remote (and use --force if needed)

To prevent this from happening again, you should check the .gitignore in the repository (and optionally setup a hook on server)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!