Skip to content

Commit 3b0185e

Browse files
author
eliranm
committed
add a tip to remove sensitive data from history (after a push)
1 parent 325f7bc commit 3b0185e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
1414
* [Everyday Git in twenty commands or so](#everyday-git-in-twenty-commands-or-so)
1515
* [Show helpful guides that come with Git](#show-helpful-guides-that-come-with-git)
1616
* [Search change by content](#search-change-by-content)
17+
* [Remove sensitive data from history, after a push](#remove-sensitive-data-from-history-after-a-push)
1718
* [Sync with remote, overwrite local changes](#sync-with-remote-overwrite-local-changes)
1819
* [List of all files till a commit](#list-of-all-files-till-a-commit)
1920
* [Git reset first commit](#git-reset-first-commit)
@@ -187,6 +188,11 @@ git help -g
187188
git log -S'<a term in the source>'
188189
```
189190

191+
## Remove sensitive data from history, after a push
192+
```sh
193+
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all
194+
```
195+
190196
## Sync with remote, overwrite local changes
191197
```sh
192198
git fetch origin && git reset --hard origin/master && git clean -f -d

tips.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
}, {
88
"title": "Search change by content",
99
"tip": "git log -S'<a term in the source>'"
10+
}, {
11+
"title": "Remove sensitive data from history, after a push",
12+
"tip": "git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all"
1013
}, {
1114
"title": "Sync with remote, overwrite local changes",
1215
"tip": "git fetch origin && git reset --hard origin/master && git clean -f -d"

0 commit comments

Comments
 (0)