Deleting files on Github after push

Asked

Viewed 464 times

3

I created my first repository to study on git and github, did my first commits and pushes in the remote repository, and only then did I realize that I had a file I didn’t want, how do I get it out of the repository on github? NOTE: I already put this file the . gitignore and even then the file is not deleted from the remote repository.

3 answers

3

Do the following:

  1. Comment the file line on .gitignore
  2. Remove it from the local directory, copy to another folder
  3. Update the index -> git add
  4. Perform the commit
  5. Perform the push to the remote repository
  6. Remove the comment from the file line on .gitignore
  7. Copy it again to the local directory

3


In the terminal, inside the folder of your project, you can do the following:

git init
git rm --cached NOME_DO_ARQUIVO
git commit -m "Apagar arquivo"
git push origin master
  • The answer was edited to delete from Github only

2

One simple way to remove a file from a repository on GITHUB is through the github WEB interface itself.

Just access the file you want to delete and click on delete button, He looks like a dumpster in top right corner of the screen.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.