简体   繁体   中英

How to edit or update a file for all commits and branches in git, using git filter-branch?

I am trying to update the Repository URL in the package.json file in all of my branch and commits on my repo. There are multiple wayS to approach as always, I have tried to use git filter-branch delete the file in all commits and add new file back.

This is how I delete my file: git filter-branch --index-filter 'git rm --cached --ignore-unmatch package.json' HEAD And now, I am trying to add a new package.json file with new git url.

Is there a better way to do this? I just want to update my git url in packagae.json since my old url content sensitive information of my company.

Thanks.

You could try using BFG Repo-Cleaner

It has bfg --delete-files or bfg --replace-text which would allow you to remove a file (or replace some text within that file)

See more at " Removing sensitive data from a repository ".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM