1

I have created an Eclipse project from an existing Git repository.

It contains some sample documents and code, but i find it easier to delete them and start from scratch.

Will the old documents be deleted in the repository without any trouble the next time i do commit and push?

CarlosT
  • 181
  • 1
  • 18
  • Only if you flagged them as such iirc, otherwise it'll just download them again. This is why git add and [remove](https://stackoverflow.com/questions/2047465/how-can-i-delete-a-file-from-git-repo) exist for files right? – G_V Feb 15 '18 at 10:57

2 Answers2

1

Follow the following steps :

NOTE : origin here refers to your remote project location.

Step 1 : From command line navigate to project directory where your working

Step 2 : In command line run the following commands

   git pull origin master /* Just to make sure you will get all the latest files from remote repository where you have hosted your project */

   git rm * /* To remove all the files from you current directory */
       OR
   git rm file1.txt file2.txt /* to remote specific files */

   git add . /* Add the deleted files for staging */

   git commit -m "Removed obsolate files" /* Commit the deleted files into your local repository */

   git push origin master /* Now push to the remote repository all the changes that you have done, all the deleted files will be now removed from remote repository */

Step 3 : Now you can start working with your fresh files

Channaveer Hakari
  • 2,769
  • 3
  • 34
  • 45
0

If you want to delete a file, use git rm ${fileName} (in case you want to delete in only in git, but keep it locally, use the --cached flag. After that, once you commit and push, the changes will be available in the repo.

Ondra K.
  • 2,767
  • 4
  • 23
  • 39