Skip to main content
Simplify text around refactor. Editorialize a bit more under the lesson.
Source Link

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for .pem files in all tracked folders:

git log --all --stat -- ':**/*.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, thatsearch text might be -----BEGIN or PRIVATE KEY. 

This first command runs faster, but disregards file renames or matched instances that are added and removed from the same file or wholesale file renames. ThisThe optimization mostly ignores refactors, but might also miss what you're looking for under rare, unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you herewith your assignment, but you can also search commit messages. Sensitive data is usually added along with other files in innocuous-sounding commits. But sometimes you get lucky and the commit that removes the sensitive data says what it's doing.

git log --all --stat -i --grep='key|secret|sensitive|private|credential|password'

Lesson

If you or someoneanyone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

There are several ways to manage sensitive data. Whichever one you choose, you want to make it hard for a contributor to do the wrong thing.

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for .pem files in all tracked folders:

git log --all --stat -- ':**/*.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but disregards matched instances that are added and removed from the same file or wholesale file renames. This ignores refactors, but might also miss what you're looking for under rare, unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you here, but you can also search commit messages. Sensitive data is usually added along with other files in innocuous-sounding commits. But sometimes you get lucky and the commit that removes the sensitive data says what it's doing.

git log --all --stat -i --grep='key|secret|sensitive|private|credential|password'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for .pem files in all tracked folders:

git log --all --stat -- ':**/*.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, search text might be -----BEGIN or PRIVATE KEY. 

This first command runs faster, but disregards file renames or matched instances that are added and removed from the same file. The optimization mostly ignores refactors, but might miss what you're looking for under rare, unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help with your assignment, but you can also search commit messages. Sensitive data is usually added along with other files in innocuous-sounding commits. But sometimes you get lucky and the commit that removes the sensitive data says what it's doing.

git log --all --stat -i --grep='key|secret|sensitive|private|credential|password'

Lesson

If you or anyone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

There are several ways to manage sensitive data. Whichever one you choose, you want to make it hard for a contributor to do the wrong thing.

More accurate diffcore summary.
Source Link

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for it.pem files in all tracked folders:

git log --all --stat -- ':**/key*.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but needs the count of matchdisregards matched instances inthat are added and removed from the whole repository to changesame file or wholesale file renames. This ignores refactors and moved files, but might also miss what you're looking for under rare, unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you here (but worth noting in general) that, but you can also search commit messages. Sensitive data is usually added along with other files in innocuous-sounding commits. But sometimes you get lucky and the commit that removes the sensitive data says what it's doing.

git log --all --stat -i --grep='key'grep='key|secret|sensitive|private|credential|password'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for it in all tracked folders:

git log --all -- ':**/key.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but needs the count of match instances in the whole repository to change. This ignores refactors and moved files, but might also miss what you're looking for under unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you here (but worth noting in general) that you can also search commit messages.

git log --all --stat -i --grep='key'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

Your hint says that the "HTTPS private key has been forgotten in Git." This could mean several things, but I suspect it means that the private key was added and deleted from Git history, which in turn means you can get it back.

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for .pem files in all tracked folders:

git log --all --stat -- ':**/*.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but disregards matched instances that are added and removed from the same file or wholesale file renames. This ignores refactors, but might also miss what you're looking for under rare, unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you here, but you can also search commit messages. Sensitive data is usually added along with other files in innocuous-sounding commits. But sometimes you get lucky and the commit that removes the sensitive data says what it's doing.

git log --all --stat -i --grep='key|secret|sensitive|private|credential|password'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

Subheadings
Source Link

Trawling Git

Trawling GitQuick peek

If the Git history is short,1 you can justshort, git log --oneline --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

If theIn an assignment like this with mocked up Git history is long,, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try fancier thingshunting for it. This path filter will check all for it in all tracked folders:

git log --all -- ':**/key.pem'

Filtering for text changes

If you have some text in mind to huntlook for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but needs the count of match instances in the whole repository to change. This ignores refactors and moved files, but might also miss what you're looking for under unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, likebut it checks for the text in every commit.

  • git log --all -- with a file filter.

    Since your ps aux output says --key=/root//key.pem, try using :**/key.pem to look for key.pem in all tracked folders.

  • git log --all -i --pickaxe-regex -S with some text to look for in the diff.2

    This runs faster than the next command, but needs the count of the searched text to change in a commit. (Most of the time, that just means it ignores boring refactors.)

  • git log --all -i -G with some text to look for in the diff.2

    This runs slower than the previous command because it requires two passes through the history, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Lesson

Filtering for commit message

It's unlikely to help you here (but worth noting in general) that you can also search commit messages.

git log --all --stat -i --grep='key'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

1 In an assignment like this with mocked up Git history, git log --stat and the pager might be enough.
2 Search for text like -----BEGIN or "PRIVATE KEY".

Trawling Git

If the Git history is short,1 you can just git log --oneline --stat, Ctrl+D until you find the right commit, and git show it.

If the Git history is long, you can try fancier things to hunt for it, like

  • git log --all -- with a file filter.

    Since your ps aux output says --key=/root//key.pem, try using :**/key.pem to look for key.pem in all tracked folders.

  • git log --all -i --pickaxe-regex -S with some text to look for in the diff.2

    This runs faster than the next command, but needs the count of the searched text to change in a commit. (Most of the time, that just means it ignores boring refactors.)

  • git log --all -i -G with some text to look for in the diff.2

    This runs slower than the previous command because it requires two passes through the history, but it checks for the text in every commit.

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

1 In an assignment like this with mocked up Git history, git log --stat and the pager might be enough.
2 Search for text like -----BEGIN or "PRIVATE KEY".

Trawling Git

Quick peek

If the Git history is short, git log --stat and the pager might be enough. Run the command below, Ctrl+D until you find the right commit, and git show it.

git log --all --stat --oneline

In an assignment like this with mocked up Git history, that's probably all you need. If not, you can take a closer look:

Deeper dive

Filtering for files

Since your ps aux output says --key=/root//key.pem, try hunting for it. This path filter will check all for it in all tracked folders:

git log --all -- ':**/key.pem'

Filtering for text changes

If you have some text in mind to look for in a delta, there are two ways to do so. For you, that might be -----BEGIN or PRIVATE KEY. This first command runs faster, but needs the count of match instances in the whole repository to change. This ignores refactors and moved files, but might also miss what you're looking for under unexpected circumstances.

git log --all --stat -i --pickaxe-regex -S'private key'

This next command takes two passes through the history, making it slower than the previous one, but it checks for the text in every commit.

git log --all --stat -i -G'private key'

Filtering for commit message

It's unlikely to help you here (but worth noting in general) that you can also search commit messages.

git log --all --stat -i --grep='key'

Lesson

If you or someone on your team puts secret data into Git, you can't just git rm it away. Its content stays there in the history forever. You need to use a tool like git filter-repo or git filter-branch to get rid of it, and everyone with a clone of the repo who has fetched it since the secret was introduced needs to fix theirs, too. This might mean throwing their repo away and cloning a fresh copy.

Recursive path search.
Source Link
Loading
Move another parenthetical to a footnote
Source Link
Loading
Footnote.
Source Link
Loading
Preempt anyone who complains that Git is snapshot-based, not delta-based.
Source Link
Loading
Preempt anyone who complains that Git is snapshot-based, not delta-based.
Source Link
Loading
Why is this important?
Source Link
Loading
Source Link
Loading