-1

I unintentionally push a code with passwords to bit bucket. and i found out that i need to remove this file using below command.

git filter-branch --tree-filter 'git rm -rf app\Http\xxxx.php' 1xeeeee..HEAD

I'm using windows and the repo is in gitbucket.

and i'm trying to execute the command in the windows command propmt and it's displaying error below.

fatal: ambiguous argument 'rm': unknown revision or path not in the working tree.

I think the error is because i'm in the windows and the file is in the bitbucket.

is there any other way to delete a specific file from history in bitbucket?

And also is it possible to do SSH in bitbucket? so i can execute the command there.

1615903
  • 32,635
  • 12
  • 70
  • 99
Rabb-bit
  • 805
  • 12
  • 24
  • http://stackoverflow.com/questions/2047465/how-can-i-delete-a-file-from-git-repo ... try this – RïshïKêsh Kümar May 08 '17 at 09:20
  • @RïshïKêshKümar No, that's not the same, he wants to eradicate the file from history as well, not just commit a deletion of the file. He needs to rewrite history so he's on the right path. – Lasse V. Karlsen May 08 '17 at 09:27
  • http://stackoverflow.com/a/872700/276193 – learnvst May 08 '17 at 09:27
  • You shouldn't use `git rm`, you should simply remove the file on disk, git will pick up that change, try simply removing `git` from that command, otherwise, since you're on Windows , you might need to use `del`, but since `git` spawns bash, `rm` might still be the way to go. – Lasse V. Karlsen May 08 '17 at 09:28
  • Besides, GitHub has also posted a FAQ for this particular question: [Removing sensitive data from a repository](https://help.github.com/articles/removing-sensitive-data-from-a-repository/) – Lasse V. Karlsen May 08 '17 at 09:31
  • 1
    Possible duplicate of [Remove sensitive files and their commits from Git history](http://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-commits-from-git-history) – Lasse V. Karlsen May 08 '17 at 09:32
  • @LasseV.Karlsen yes, thank you for your help. yes, i've read the docs. – Rabb-bit May 08 '17 at 10:07

1 Answers1

1
  1. You should use --index-filter, not --tree-filter. It is much faster as it does not need a worktree and for deletion it will work fine.
  2. When using --index-filter, use --cached for the git rm, so that the rm only works on the index, there is no worktree with --index-filter.
  3. Add --ignore-unmatch to git rm to ignore if the file is not present in the commit that is currently rewritten. (This is the cause for the actual error message you are getting)
  4. filter-branch is a purely local command and only changes your local repository. Thus there is no relation to whether this is on BitBucket or not if something works or not. After you verified the result is as expected you have to force-push to BitBucket to overwrite the repo there with your rewritten version.
  5. No, you cannot SSH into BitBucket, except maybe if you work for Atlassian.
Vampire
  • 35,631
  • 4
  • 76
  • 102