简体   繁体   中英

.gitignore not ignoring files

Here is my .gitignore file:

# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp

# Ignore application configuration
/config/application.yml
/config/application.yml.bak
*.bak

Now, my repository is at https://github.com/rmohan80/learn-rails

Why would my latest commit -- "add configuration for email" add Readme.rdoc.bak but ignore .gitignore.bak

Any clues?

The star character does do match files beginning with a period. You can add .*.bak to ignore them in your case or you can change the glob option in your shell :

# capture dot file
shopt -s dotglob

# do git stuff here

# stop capturing dot file
shopt -u dotglob

A similar problem solved here : https://stackoverflow.com/a/19365350

You have to checkout the HEAD, so that your repository looks unmodified. Then run the following:

$ echo '*.*.bak' >> .gitignore

To exclude files that are formatted like README.md.bak .

And run

$ echo '**/*.bak' >> .gitignore

to exclude files that are formatted like README.bak anywhere in the tree below the current directory.

Having .bak.bak files is something you don't want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM