Usecase- There's a SSH file included in your repo; but you want to remove it. Removing it from current commit won't delete from all the history. This command will save your life.
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
--prune-empty --tag-name-filter cat -- --all
and if that's a directory, include -r
:
git filter-branch --force --index-filter \
'git rm -r --cached --ignore-unmatch PATH-TO-YOUR-DIR-WITH-SENSITIVE-DATA' \
--prune-empty --tag-name-filter cat -- --all
rsync -a DIRECTORY-PATH your_username@your_IP:/home/your_username/
This will upload the whole directory in DIRECTORY-PATH
to your home/your_username/
dir of your remote address.
find . -name "*.extension" | xargs grep -i "some text" >> output.txt
grep -Ril "text to search" /path/to/dir >> ~/Desktop/output.txt
git reset HEAD <file-path>
git checkout -- <file-path>