Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git accidental inclusion of password..how do I fix it?

Tags:

git

github

On a commit I accidentally included a password. How do I remove this commit from the repository?

The push went to github so It's important that the commit be removed completely from the history.

like image 477
SooDesuNe Avatar asked Feb 24 '11 01:02

SooDesuNe


People also ask

How do I fix Git always asking for credentials?

Entering Git Username and Password in Remote URL To prevent Git from asking for your username and password, you can enter the login credentials in the URL as shown. The main drawback of this method that your username and password will be saved in the command in the Shell history file.

How do I delete a Git secret?

If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-branch command or the BFG Repo-Cleaner open source tool.

What could be the possible reason for Git prompting for a password?

If Git prompts you for a username and password every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository. Using an HTTPS remote URL has some advantages: it's easier to set up than SSH, and usually works through strict firewalls and proxies.


1 Answers

You should do as follow:

git log --oneline -S <COMMIT_SEARCH_PATTERN>

# Copy the commit hash

git rebase - i <COMMIT_HASH>~1

# Change the marker to **drop**
# Exit from the editor

git rebase --continue
git push --force

like image 148
Antonio Petricca Avatar answered Oct 09 '22 05:10

Antonio Petricca