From 3b0185e443910f215b98e5b001e6d87bea536f30 Mon Sep 17 00:00:00 2001 From: eliranm Date: Mon, 30 Oct 2017 12:24:22 +0200 Subject: [PATCH] add a tip to remove sensitive data from history (after a push) --- README.md | 6 ++++++ tips.json | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9161377..20349b2 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`. * [Everyday Git in twenty commands or so](#everyday-git-in-twenty-commands-or-so) * [Show helpful guides that come with Git](#show-helpful-guides-that-come-with-git) * [Search change by content](#search-change-by-content) +* [Remove sensitive data from history, after a push](#remove-sensitive-data-from-history-after-a-push) * [Sync with remote, overwrite local changes](#sync-with-remote-overwrite-local-changes) * [List of all files till a commit](#list-of-all-files-till-a-commit) * [Git reset first commit](#git-reset-first-commit) @@ -187,6 +188,11 @@ git help -g git log -S'' ``` +## Remove sensitive data from history, after a push +```sh +git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all +``` + ## Sync with remote, overwrite local changes ```sh git fetch origin && git reset --hard origin/master && git clean -f -d diff --git a/tips.json b/tips.json index 92d1b38..c5c7924 100644 --- a/tips.json +++ b/tips.json @@ -7,6 +7,9 @@ }, { "title": "Search change by content", "tip": "git log -S''" +}, { + "title": "Remove sensitive data from history, after a push", + "tip": "git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch ' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all" }, { "title": "Sync with remote, overwrite local changes", "tip": "git fetch origin && git reset --hard origin/master && git clean -f -d"