0

I added files that need to be ignored,but IntellIJ Idea continue to add t in Repository.I deleted previous repository, and create a new to check will it be working, and it still cannot be ignored.Does anyone know, what the can be problem here?

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.tar.gz
*.rar
*.iml

# Project gen files
.idea
.allure/
.gradle/
allure-results/
gradle/
build/
bin/
out/
logs/
target/
.classpath
.project
.settings/org.eclipse.buildship.core.prefs
.vscode
/gradlew
/gradlew.bat
.todo
*.properties

Thats only added my commit for files

Azeem
  • 11,148
  • 4
  • 27
  • 40
hamziejam
  • 21
  • 3
  • Could you please clarify if you have pushed this gitignore file to your repo. If not then you have to push this file to the repo in order to ignore the desired files to be ignored. – Sourabh Roy Jun 07 '23 at 01:16
  • Also, if files were tracked by Git before you added them to `.gitignore`, Git doesn't just forget about them, see [How do I make Git forget about a file that was tracked, but is now in .gitignore?](https://stackoverflow.com/q/1274057/3266847) – Benjamin W. Jun 07 '23 at 03:24

2 Answers2

0

You can try to (in local):

  1. git rm -rf --cached
  2. git add .
  3. git commit -m "init"
  4. git push
Xiang
  • 230
  • 2
  • 10
0
  1. Check the location of your .gitignore file: Make sure the .gitignore file is placed in the root directory of your repository. If it's located in a subdirectory, it may not be effective for files in other directories.

  2. Verify the patterns in your .gitignore file: Double-check that the patterns specified in your .gitignore file are correct and match the files or directories you want to ignore. Here are a few tips:

  3. Use relative paths: Patterns in the .gitignore file are relative to its location. For example, to ignore a file named example.txt, the pattern should be example.txt.

  4. Use wildcards: You can use wildcards like * to match multiple characters or ** to match directories recursively.

  5. Check for leading slashes: A leading slash / at the beginning of a pattern makes it match from the root directory of the repository. Without a leading slash, the pattern matches files or directories anywhere in the repository.

  6. Ensure the files are not already tracked: If the files you want to ignore are already being tracked by Git, the .gitignore file won't have any effect on them. You'll need to remove them from Git's tracking using the git rm --cached command. For example: git rm --cached example.txt.

  7. Check for global or local exclude files: Git also looks for global and local exclude files ~/.gitignore and .git/info/exclude respectively that can contain additional ignore patterns. Make sure these files are not conflicting with the patterns in your .gitignore file.

  8. Verify Git version and configuration: Some versions of Git may have issues with specific patterns or configurations. Make sure you're using an up-to-date version of Git. Additionally, check if there are any specific configuration settings, such as git config that could be affecting the behavior of .gitignore rules.

  9. Cache issue: If you recently added or modified the patterns in your .gitignore file, it's possible that Git's cache still remembers the old state. You can clear the cache using the following command: git rm -r --cached . && git add ..

Martin
  • 628
  • 1
  • 9
  • 28
Suresh
  • 1
  • 3