It allows you to delete files or, alternatively, replace the passwords or keys within the file with the text ***REMOVED***. To remove the sensitive file from your history as well, you can use an open-source tool called the BFG Repo-Cleaner or use git's git filter-branch.īFG Repo-Cleaner apparently makes it much easier and faster to get the job done compared to filter-branch. If the pushed file has sensitive data like passwordsĪs noted by Ölbaum's comment below (thanks!), the above method will not completely remove the file from the commit history. Of course, if you just don’t need the file any more at all, simply delete it from your system as well.īUT! If the file had sensitive data like passwords or secret keys, then you need to do a little bit more because the commits can still be found in the repository's history. To prevent it from being pushed to Git again, just add the file to your. This will not delete it locally, so it is safe on your computer if you want to keep it in there for reference without sharing on Git. However, those commits will still be available in their reflogs, so they can restore them using steps like the above.Enter fullscreen mode Exit fullscreen mode Any commits pushed by others after the last time you fetched will be lost. Note, however, that this restores remote master to the state most recently retrieved by git fetch or equivalent. # finally, push the master branch (and only the master branch) to the server # (if necessary, use git reflog to find the right one, and Git reset -hard at this point verify that this is indeed the desired commit. # reset to the previous state of origin/master, as recorded by reflog The steps involved typically look like this: # work on local master You can always restore the previously observed state of master, by resetting to the old commit and issuing another push -f. If you're on an in-house (or other non-github) installation, read on. When working with github, refer to GHugo's answer which gives a foolproof procedure with github. How can I recover from it without messing up other contributors' history? Then I accidentally used git -f push, which overwrote the remote branch and now I lost the commits from the pull requests on remote repository. Thus, I think my origin/master is two versions behind the remote master. Then, I didn't fetch the master branch on my local machine. I integrate two pull requests by using the GitHub's Auto merge pull requests. Is there some other way to recover from this disaster? I learned the -force is a really, really bad choice. So my problem is: can I reopen the pull request and remerge? I noticed that there is commit version for merge request, so I am worried if I simply make new pull request it will mess up something? Ideally I just want to redo the merging of the two requests. Basically, my remote master has two pull requests merged ahead of my local master. Luckily, my local branch is not too far away from the remote. Then, a disaster happened, as I pushed my local master branch to the remote repository. For some reason I have to use git push -force for the feature1 branch, but I didn't know when I use git push -force it will also push the master branch. I have two remote git branches: master and feature1.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |