I just realized that I made one commit
that includes a password. The problem is that I already uploaded the changes to the source repository.
How can I repair it without losing the changes I made and without leaving the password in the repository history?
You have to do the commit again, for that you can see how here , then you have to push forcing your version:
If someone else has already pulled those changes, it can cause problems, but if you are only working with it, it is safe.
You could use git rebase, to remove the last commit.
You must comment the line of code corresponding to commit, save and exit the editor.
later run
For this you must:
1) Locate the server commit. You can get the last 10 commits like this:
That shows you the hashes of the commits
2) Locate the desired point and return to the desired commit
3) Push the changes to the repository server
And ready. It is used to return any commit.
You have to remove the commits from your local repository and then force that to be the last state with the option
-f
For example to remove 10 commits
and then force that to be the state in origin
More on how to remove commits from local history:
How can I undo the last commit in Git?
Delete the commit in the local repository but do not save the changes made:
Delete the commit in the local repository and save the changes made:
Subsequently, it can be forcefully pushed to the remote repository.