danielsvane
danielsvane

Reputation: 613

Remove files from master at github

First time playing with git, and I accidentally added all hidden files with my commit. Now that I have set up my .gitignore, and committed my changes, all the files ending with "~" are still there.

How do I commit my local files, and remove those from master that are not supposed to be there any more?

Upvotes: 8

Views: 13943

Answers (2)

user3280979
user3280979

Reputation: 9

Here is a DOS batch file that can help:

SET count=1
FOR /F "tokens=*" %%G IN ('dir /s /b *.dll') DO (call :subroutine "%%G")
FOR /F "tokens=*" %%G IN ('dir /s /b *.pdb') DO (call :subroutine "%%G")
FOR /F "tokens=*" %%G IN ('dir /s /b *.txt') DO (call :subroutine "%%G")
FOR /F "tokens=*" %%G IN ('dir /s /b *.cache') DO (call :subroutine "%%G")
FOR /F "tokens=*" %%G IN ('dir /s /b *.force') DO (call :subroutine "%%G")
GOTO :eof

 :subroutine
  git rm --cached %1
  set /a count+=1
  GOTO :eof

Upvotes: 0

QuantumBlack
QuantumBlack

Reputation: 1546

Use git rm --cached FILENAME to delete it from the repository but keep the file physically and git add FILENAME to add a file to your repository. You will need to commit both of these changes with git commit

Upvotes: 17

Related Questions