dvliman
dvliman

Reputation: 606

How can I delete files in the remote repository?

I am not sure what is the exact term for this problem. Basically, I need to remove some files & directory on my remote repository

I have a local Git repository and remote repository on GitHub

  1. Had been working myself.
  2. A friend made a pull request.
  3. I merged his request (via the GitHub interface)
  4. I pulled the changes.
  5. I tested the code and decided not to take his changes (shouldn't have merged at the first place)
  6. I reverted back to a previous commit
  7. Made some changes
  8. Push to the server.

This is how my local repository looks like at the moment:

*   7e143b1  (HEAD)
|\
| *   18cea0f  (origin/master, origin/HEAD, master)
| |\
| | * fc19ccf
* | | 6f3c58a
|/ /
* | 8d82486
|/
| * d3ce65f  (pre-install-activeadmin)
|/
* 7d0566c
* d1c77ab
* 75ba704
* 30dc67c  (heroku/master)
* f89b1f6
* ea5e2db
* 08931d6
* 9773a6f
* b636aba
* cb6f8d4

I can change my local repo to 7d0566c. I am not sure where the head on my remote repository is pointing to.

How do I remove those files that are on remote repo but are not on my local repository?

Obviously, I do not see any of his files in my local repo because I did a reset of my HEAD to a previous commit. However, the remote repo still shows his files. When I commit, it commits just fine.

Is my workflow wrong? I should have just tested the patch at the first place.

Upvotes: 19

Views: 52057

Answers (2)

htanata
htanata

Reputation: 36944

I'm assuming 18cea0f is where your pull request merge happened. In order to revert that merge, you can do:

git revert -m 1 18cea0f

You can read more here: http://progit.org/2010/03/02/undoing-merges.html

Upvotes: 1

Ry-
Ry-

Reputation: 224903

Pull the changes from the server, then do a git rm on your local repo, commit the changes, and push to the server. The files will be deleted.

Upvotes: 42

Related Questions