Delete a single file from remote GitHub repository

Hi there,

I am new to GitHub, and I've gone through a few video tutorials and GitHub help articles, but I still don't think I understand how it works.

Can a single file in my remote GitHub repository be deleted from a GitBash command prompt on my computer?

I've tried this from GitBash:
$ git remote rm
 error: Could not remove remove config section 'remote.'

Open in new window

The error doesn't sound good, so I assume it's the wrong command??
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think it's easier to remove from your local copy of the repository and then push the changes to the remote. in that case, you'd open a command line and go to the root folder of your local repo. You then have a few options:

If you want to delete the file from the repo, but leave it in the the file system (will be untracked):
git rm --cached
git commit -m "Deleted from the repo"

Open in new window

If you want to delete the file from the repo and from the file system then there are two options:

If the file has no changes staged in the index:
git rm
git commit -m "Deleted"

Open in new window

If the file has changes staged in the index:
git rm -f
git commit -m "Deleted"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
userTesterAuthor Commented:
Thanks MlandaT,

What do you mean by
If the file has no changes staged in the index
Basically... just if the file you are deleting has any changes that havent been pushed/committed.
userTesterAuthor Commented:
Thanks Mlanda, it worked perfectly!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.