Delete everything and upload new version

后端 未结 3 812
悲哀的现实
悲哀的现实 2021-02-04 09:45

We are using git for version control and right now we are getting a lot of warnings when trying to upload the most recent version. I am new to git and don\'t have patience for t

3条回答
  •  攒了一身酷
    2021-02-04 10:15

    If you want to permanently delete the files from the remote repository and in retrospect as if they weren't pushed in the first place to start fresh, then base on this answer you could do the following

    Run the following locally (Notice the * deletes every folder/file):

    git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch *" -- --all
    

    Now it's time to update git references locally to enforce it to forget all the history it had of those files

    rm -rf .git/refs/original/
    
    git reflog expire --expire=now --all
    
    git gc --prune=now
    
    git gc --aggressive --prune=now
    

    Now push all the changes to the remote repository with a FORCE to ensure the remote repo also clears all those files

    git push --all --force
    

    This would clean up the remote repository as if no file ever existed.

提交回复
热议问题