1

I'm facing a problem on a git ..

I did accidentally commit a piece of API information to the git remote repository:
I want to remove API information but keep "SKIP_PREFLIGHT_CHECK=true" in the file.

I did

I tried to delete the previous commit by using a

git reset --hard <id>

but that's not working ..

My default branch is develop.
But now I'm working on feature branch.

I'm not yet merging the feature to the dev branch.

In this situation, what's the best option for me?
This is a personal project.

I Want

What I want to the thing is to remove only API information and keep .env. file in the feature branch (delete the history)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Taiga
  • 165
  • 3
  • 16

1 Answers1

2

You should use git filter-repo (that I mentioned here).

Install it first. (python3 -m pip install --user git-filter-repo)

Then:

git filter-repo --replace-text <(echo 'my_api-information==>xxxxxxxx') HEAD

# Or, for only the last 2 commits:
git filter-repo --refs HEAD~2..HEAD --replace-text <(echo 'my_api-information==>xxxxxxxx')

HEAD means it will change only your current branch commits.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250