Skip to content
Fix Code Error

How to ignore certain files in Git

March 13, 2021 by Code Error
Posted By: Anonymous

I have a repository with a file, Hello.java. When I compile it, an additional Hello.class file is generated.

I created an entry for Hello.class in a .gitignore file. However, the file still appears to be tracked.

How can I make Git ignore Hello.class?

Solution

The problem is that .gitignore ignores just files that weren’t tracked before (by git add). Run git reset name_of_file to unstage the file and keep it. In case you want to also remove the given file from the repository (after pushing), use git rm --cached name_of_file.

Answered By: Anonymous

Related Articles

  • Eclipse will not start and I haven't changed anything
  • How can I resolve Web Component Testing error?
  • TLS 1.3 server socket with Java 11 and self-signed…
  • Maven2: Missing artifact but jars are in place
  • Unable to run Robolectric and Espresso with a…
  • ClassNotFoundException:…
  • When I'm testing a web app by JUnit and Mockito I…
  • Jetpack Compose and Hilt Conflict
  • java IO Exception: Stream Closed
  • Neither BindingResult nor plain target object for…
  • JUNIT @ParameterizedTest , Parameter resolution Exception
  • Various ways to remove local Git changes
  • SecurityException: Permission denied (missing…
  • Execution failed for task…
  • Android- Error:Execution failed for task…
  • Gradle error: Execution failed for task…
  • SQLException: No suitable Driver Found for…
  • Examples of GoF Design Patterns in Java's core libraries
  • android studio 0.4.2: Gradle project sync failed error
  • Can't access Eclipse marketplace
  • Using enums in a spring entity
  • Requested bean is currently in creation: Is there an…
  • org.gradle.api.tasks.TaskExecutionException:…
  • GLYPHICONS - bootstrap icon font hex value
  • Git command to show which specific files are ignored…
  • In plain English, what does "git reset" do?
  • AppCompat v7 r21 returning error in values.xml?
  • Could not install Gradle distribution from…
  • How to parse JSON file with Spring
  • JPA Hibernate Persistence exception…
  • Android Studio 4.2.1 NullPointer Exception on startup
  • Configure hibernate to connect to database via JNDI…
  • Launching Spring application Address already in use
  • How do I ignore files in Subversion?
  • Why are there two ways to unstage a file in Git?
  • Mock MQRFH2 header in JUnit Testing Error [MQRFH2…
  • UnsatisfiedDependencyException: Error creating bean…
  • How to add Typescript to a Nativescript-Vue project?
  • How to track untracked content?
  • Failed to execute goal…
  • Error inflating class android.support.v7.widget.Toolbar?
  • Plugin…
  • How to convert java.util.Date to java.sql.Date?
  • Problems using Maven and SSL behind proxy
  • Eclipse fails to open .vue files in Web Page Editor
  • How do I install Java on Mac OSX allowing version switching?
  • Spring Boot with ElasticSearch in Groovy: WebClient…
  • Getting Dropwizard Client And Jersey/HTTP I/O Error…
  • java.lang.ClassNotFoundException: HttpServletRequest
  • ClassNotFoundException thrown
  • Vaadin Spring Boot - There was an exception while…
  • git lfs push to github failure on Ubuntu 18.04
  • Resync git repo with new .gitignore file
  • An Authentication object was not found in the…
  • "Non-resolvable parent POM: Could not transfer…
  • Spring Boot - Cannot determine embedded database…
  • Java.lang.NoClassDefFoundError:…
  • Gradle: Execution failed for task ':processDebugManifest'
  • What's the difference between eval, exec, and compile?
  • What's the difference between Instant and LocalDateTime?
  • "git rm --cached x" vs "git reset head --​ x"?
  • java.lang.RuntimeException: Unable to instantiate…
  • error: resource android:attr/fontVariationSettings not found
  • org.springframework.beans.factory.NoSuchBeanDefiniti…
  • Why do I have to "git push --set-upstream origin "?
  • Git - Pushing code to two remotes
  • Why do git fetch origin and git fetch : behave differently?
  • Eclipse - Run in Debug Mode fails
  • Aurelia UX showcase app fails to load
  • What's causing my java.net.SocketException:…
  • Why am I getting a "401 Unauthorized" error in Maven?
  • How does PHP 'foreach' actually work?
  • Injection of autowired dependencies failed;
  • Java ElasticSearch None of the configured nodes are…
  • What does "Could not find or load main class" mean?
  • Address already in use: JVM_Bind
  • Checkout another branch when there are uncommitted…
  • Spring schemaLocation fails when there is no…
  • using reset on a collection vs add - why do they…
  • What is a stack trace, and how can I use it to debug…
  • Git Using Remote Branch
  • What's the difference between "git reset" and "git…
  • Exception : AAPT2 error: check logs for details
  • Android Gradle plugin 0.7.0: "duplicate files during…
  • Maven does not find JUnit tests to run
  • Why won't my tracked array update in Ember Octane?
  • Reference - What does this regex mean?
  • Spring Security exclude url patterns in security…
  • How do I make a Git commit in the past?
  • Multipart File Upload Using Spring Rest Template +…
  • git pull while not in a git directory
  • RxJava Main Thread Always Crash
  • Jetty server throws idle timeout for REST calls
  • Get rid of several bad commits
  • NullpointerException error while working with…
  • How to disable SSL certificate checking with Spring…
  • java.net.UnknownHostException: Unable to resolve…
  • git: How to ignore all present untracked files?
  • Are multiple `.gitignore`s frowned on?
  • How to test Spring Data repositories?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to get the browser to navigate to URL in JavaScript

Next Post:

Should I use != or for not equal in T-SQL?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error