Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove files from the GitHub repository?

Tags:

git

github

I deleted python .pyc files from my local repo and what I thought I did was to delete from remote github.

I pushed all changes. The files are still on the repo but not on my local machine. How do I remove files from the github repo?

I tried the following:

git rm classes/file.pyc
git add .
git 

and even:

git rm --cached classes/file.pyc

Then when I try and checkout the files I get this error.

enter code here`error: pathspec 'classes/redis_ha.pyc' did not match any file(s) known to git.

I now dont know what else to do. As of now I have a totally corrupted git repo.

like image 247
Tampa Avatar asked Jun 20 '12 14:06

Tampa


People also ask

How do I delete a file from my repository?

Delete Files using git rm. The easiest way to delete a file in your Git repository is to execute the “git rm” command and to specify the file to be deleted. Note that by using the “git rm” command, the file will also be deleted from the filesystem.

How do I remove all files from a remote repository?

Just in case anyone wants to delete all the files from the directory, use -r option for recursive. So the command will look like git rm -r /path-to-file-name/ then do the commit and push as mentioned in the above answer.

Which command is used to remove a file from a git repository?

The git rm command can be used to remove individual files or a collection of files. The primary function of git rm is to remove tracked files from the Git index. Additionally, git rm can be used to remove files from both the staging index and the working directory.


1 Answers

You should not do git add. That's all

git rm classes/file.pyc
git commit -m"bla bla bla"
git push
like image 190
LiMar Avatar answered Sep 21 '22 19:09

LiMar