2

I have pushed up two directories with to my Git Bitbucket repo, that I now wish to remove/delete.

How I'm a suppose to make those changes? I already tried with:

git rm -rf --cached files 
git commit -a -m "Deleted files" 
git push origin master

What I recon here is that it only removed the files from my working directory but left what it was in Bitbucket as it was.

nicoX
  • 291
  • 5
  • 16

3 Answers3

2

You can revert the commit, which you used to push those directories by the following commands

git reset --soft HEAD^

assuming the unwanted commit is at top of HEAD.

If it is lying before some commits, try this

git reset --soft HEAD~3

which reverts the changes specified by the fourth last commit in HEAD. (You need to change the number '3' based on the position of your unwanted commit.)

And check git status. You should be able to see those unwanted directory as your local changes, which is yet to be committed.

Thanks!!

Breen ho
  • 1,492
  • 12
  • 22
  • @nicoX., If you find this solution is helpful, please don't hesitate to "accept" this answer. so that, it would be helpful for future readers too!! – Breen ho Jul 23 '14 at 08:36
0

You can delete all the files in the remote branch by pushing to it an empty local branch -

Say you want to remove the origin's branch trial, then you'd do git push origin :trial

gravetii
  • 8,485
  • 8
  • 49
  • 69
0

Make sure you actually deleted the files

rm -rf directory-to-remove/

Then remove from git:

git rm -r --cached directory-to-remove/

Finally commit & push:

git commit -a -m "Deleted files"
git push origin master

Assuming your current branch is master.

Gerharbo
  • 261
  • 1
  • 6
  • It's images of a Wordpress site. I don't actually want the remove the directories, but there is no need that I have pushed 2GB of images to Bitbucket. – nicoX Jul 23 '14 at 08:25
  • Then you should add a .gitignore file in those directories and add this to git. The content of the file can be * `git add directory/.gitignore` – Gerharbo Jul 23 '14 at 08:27
  • I included them in .gitignore afterwards. – nicoX Jul 23 '14 at 08:30
  • You can exclude all the file in a specific directory by adding a '*' in the .gitignore file in the specific directory. First remove from cache `git rm -rf --cached directory-to-remove/` Make sure you're adding the .gitignore file `git add directory/.gitignore` You can check w/ `git status` which files are staged for commit. – Gerharbo Jul 23 '14 at 08:40