Reputation: 6077
I want to delete a specific folder from my bitbucket repository that doesn't exist anymore on my local project folder.
I don't want to commit everything using git commit -a because I am still working on something and I don't want to commit it yet also I am ignoring a lot of files/folders and not sure if everything is included into .gitignore ( I only commit a part of the project due to size .. ).
So instead of commiting everything for now I just want to target a specific folder and delete it from my repo. I am a git beginner .. It must be some easy solution that I don't know and the question could be asked somewhere but couldn't find anything good .. or I am doing something wrong.
Any suggestion ?
Upvotes: 0
Views: 1296
Reputation: 1847
Note 1: You should commit. Your commits will appear only in your local repository, not on bitbucket. You can amend it later before pushing to origin.
Note 2: You probably should learn to use branches on git. They are lightweight and easy to use - it will enable you to switch context of your work easily.
Note 3: You could use git stash, but I feel it may be better to commit your work instead.
So my answer would be:
$ git checkout -b my-temporary-branch # create local branch for your work
$ git add -A # add everything, that you worked on
$ git commit -m "AMEND ME LATER"
$ git fetch
$ git checkout -b temporary-master origin/master # I don't know what you committed
# to your local master already,
# that's why we're switching
# to whatever was pushed to
# bitbucket already
$ git rm -rf <directory name>
$ git commit -m "Directory removed."
$ git push origin master # publish your changes to bitbucket
$ git checkout my-temporary-branch # back to branch
$ git branch -D temporary-master # remove unnecessary branch
Then continue your work; you can fix last commit with
$ git commit --amend
Note, that you will need to either merge or rebase on top of changes in origin/master before pushing your new work back to master.
Upvotes: 1