Deleting a commit from github

Please advise on how to delete an unwanted commit from GitHub. A commit was made by mistake and when i clone with git and open the file in eclipse, it seems to open the unwanted file.

Where is this unwanted commit? Is it in a branch you made or in the main repository?

It is the branch

Generally, you can do something like git reset --hard HEAD~1 to remove a single commit, followed by git push --force to reset the commit on GitHub. If you need to remove 2 commits, you can use git reset --hard HEAD~2 and change that last number for as many commits as you like.

1 Like

I tried and it failed

Can you point me to the repo and branch you’re working on.

TRUNK-5115 opwnmrs-core-1 on Github

Ah! If it’s the only commit in the repo, you’re only choice is to delete the repo, which you can do in the “Settings” tab on GitHub. To start working on the actual issue, I would make sure you have a local copy of this: https://github.com/gracebish/openmrs-core.

If you don’t have one you can create one from the command line with the following commands:

git checkout git@github.com:gracebish/openmrs-core.git
cd openmrs-core
git remote add upstream https://github.com/openmrs/openmrs-core.git
git fetch --all --prune
git checkout -b TRUNK-5115 upstream/master

This will give you a branch to work on the ticket from that’s in line with the latest commit.

Hope that helps.

thanks. let me try it out