[RUBY] I want to delete files managed by Git

When you forget to write in .gitignore and commit "It's okay if you add it to .gitignore ..." Are you misunderstanding? Like me .. sweat

Files managed by Git will not be removed just by adding to .gitignore later, so I will write a countermeasure in such a case.

If you want to keep Git-managed files and exclude them

$ git rm --cached [File name you want to exclude]

After that, be sure to add the files you want to exclude to .gitignore. Note: Be sure to add --cached! !! If you do not add it, the entire file will be deleted.

If you want to delete the entire file

$ git rm [File name you want to delete]

If you want to delete the entire directory

$ git rm -r [Directory you want to delete]


When I started using Git, I forgot it several times and committed it, and I checked it each time, so I will keep it as a memorandum.

I hope it helps those who are in the same situation.

Recommended Posts

I want to delete files managed by Git
I want to sort by tab delimited by ruby
I want to add a delete function to the comment function
I want to convert characters ...
Swift: I want to chain arrays
I want to use FormObject well
I want to convert InputStream to String
I want to docker-compose up Next.js!
I want to recursively search for files under a specific directory
I want to give edit and delete permissions only to the poster
I want to avoid OutOfMemory when outputting large files with POI
I want to limit the input by narrowing the range of numbers
I want to judge the necessity of testing by comparing the difference of class files when refactoring Java
I want to develop a web application!
I want to write a nice build.gradle
I want to eliminate duplicate error messages
I want to make an ios.android app
I want to display background-ground-image on heroku.
I want to use DBViewer with Eclipse 2018-12! !!
I want to RSpec even at Jest!
I want to write a unit test!
I want to install PHP 7.2 on Ubuntu 20.04.
Try to implement UIAlertController by separating files
I want to perform Group By processing with Stream (group-by-count, group-by-sum, group-by-max)
I want to stop Java updates altogether
I want to use @Autowired in Servlet
I want to target static fields to @Autowired
I want to do team development remotely
[RxSwift] I want to deepen my understanding by following the definition of Observable
I want to test Action Cable with RSpec test
I want to output the day of the week
[Swift] I want to draw grid lines (squares)
I want to send an email in Java.
I want to graduate from npm install properly [2020]
I want to use arrow notation in Ruby
[Ruby] I want to do a method jump!
I want to use java8 forEach with index
I want to var_dump the contents of the intent
I want to pass APP_HOME to logback in Gradle
I want to simply write a repeating string
rsync4j --I want to touch rsync in Java.
I want to play with Firestore from Rails
[Xcode] I want to manage images in folders
I want to write quickly from java to sqlite
I want to truncate after the decimal point
Rails "How to delete NO FILE migration files"
I want to reduce simple mistakes. To command yourself.
I want to perform aggregation processing with spring-batch
[Rails] I want to load CSS with webpacker
I want to get the value in Ruby
I want to go back to a specific VC by tapping the back button on the NavigationBar!
[Rails] I want to write compactly by creating seed (% w notation, each_with_index, numbering parameter)
# 1_JAVA I want to get the index number by specifying one character in the character string.
I want to use Clojure's convenient functions in Kotlin
I want to call a method of another class
I want to do something like "cls" in Java
[Java] I want to calculate the difference from the date
I want to use NetBeans on Mac → I can use it!
I want to embed any TraceId in the log
Pointcut Expression I want to specify more than one
I want to use fish shell in Laradock too! !!