0

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 ?

2
  • git rm and commit that? Commented Jul 22, 2016 at 9:56
  • I can't do that directly because the folder doesn't exist on my local Commented Jul 22, 2016 at 11:41

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

it works, actually I figure out that the problem was with PHPstorm for some reasons is not detecting the changes/deleted files and that's what create the conflict for me .. thx for your answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.