Handle sensitive information submitted by git (roll back the GIT version library to a certain commit)

Source: Internet
Author: User
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.githubYou needDefault BranchSwitch 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 isgithubNow 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.