I have a code base which I want to push to GitHub as open source. In this Git-controlled source tree, I have certain configuration files which contain passwords. I made sure not to track this file and I also added it to the .gitignore
file. However, I want to be absolutely positive that no sensitive information is going to be pushed, perhaps if something slipped in-between commits or something. I doubt I was careless enough to do this, but I want to be positive.
Is there a way to "grep" all of Git? I know that sounds weird, but by "all" I mean every version of every file that ever existed. I guess if there is a command that dumps the diff file for every commit, that might work?
Line Log Search Simply run git log with the -L option, and it will show you the history of a function or line of code in your codebase.
Git Browsing the history Searching commit string in git logWill search for removed file string in all logs in all branches. Starting from git 2.4+, the search can be inverted using the --invert-grep option.
`git grep` command is used to search in the checkout branch and local files. But if the user is searching the content in one branch, but the content is stored in another branch of the repository, then he/she will not get the searching output.
Git can search diffs with the -S option (it's called pickaxe in the docs)
git log -S password
This will find any commit that added or removed the string password
. Here a few options:
-p
: will show the diffs. If you provide a file (-p file
), it will generate a patch for you.-G
: looks for differences whose added or removed line matches the given regexp, as opposed to -S
, which "looks for differences that introduce or remove an instance of string".--all
: searches over all branches and tags; alternatively, use --branches[=<pattern>]
or --tags[=<pattern>]
git rev-list --all | ( while read revision; do git grep -F 'password' $revision done )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With