Solve the Problem of submitting sensitive information in git (rolling back the GIT version library to a certain commit) Fri 07 June 2013
Git is a good version library. Many people now use it and create projects on GitHub. I believe everyone has had the experience of submitting versions of sensitive information. How can I delete them? It seems that only the version library is deleted. In fact, we can remove the submitted sensitive information by dropping the corresponding commit from the version library.
Back up local code
First, back up the changes to the local code to prevent loss of changes.
Roll back the commit of the Local Code
After the data is backed up, We can first roll back the local version Library
Git reset -- hard head ~ 1 # Roll back to the last commit. If it is the last n times, change 1 to the corresponding number.
Roll back the remote version Library
Next, if you submit the file directly, you will find that the file cannot be submitted. If you make a remote change, you need to pull the file first. If you use pull, you can perform the above operations in other branches.
Create a new branch and submit
git checkout -b tempgit push origin temp:temp
Rebuilding the main branch
Next, we can delete and recreate the master branch.github
You needDefault Branch
Switch to another branch (Project homepage> Settings to see)
Git push Origin -- delete master # Delete the remote master branch git branch-D master # Delete the local master branch git checkout-B master # create a new master branch and switch to the master branch git push origin master # submit main Branch
In this way, we will delete the previously submitted sensitive information (if it isgithub
Now you can switch the default branchmaster
)
Delete temporary branch
git branch -d tempgit push origin --delete temp
Category: git tagged: git sensitive information rollback commit version Library
Handle sensitive information submitted by git (roll back the GIT version library to a certain commit)