简体   繁体   中英

Git: Changes not staging when using git add * -A

Somehow, an .iml file has made its way into my git repo...

Here's how am I trying to get rid of it:

  1. I cloned the latest version to a local folder
  2. Checked out the branch that I want to merge later into master
  3. Deleted myproject.iml (using windows gui)
  4. edited .gitignore with extra line: *.iml
  5. Trying to stage the changes: git add * -A
  6. Trying to commit: git commit -m"untrack .iml file and ignore for future commits"

Problem:

On branch mybranch
Changes not staged for commit:
    modified:   .gitignore
    deleted:    myproject.iml

no changes added to commit

Why are they not staged for commit? I thought -A would stage deletions too? And also, in any way, I thought changes (like the one I made to .gitignore) are added to staging area without any special parameters?

It's weird because just before that, I committed a huge 20-file all-nighter, with changes, deletions, additions, branch within branch, all the goodies, with no problems - using the exact same procedure!

Never use ' * ' with the git add command: ' * ' means shell expansion, which, in your case, would not include any .xxx file/folder.

Simply use:

git add .

(Note the ' . ')
No need for -A , which is the default anyway, since Git 2.0 .

For more on this, see " Difference between . (dot) and * (asterisk) wildcards in Git ".

命令是“git add .”('.'而不是'*')并且不需要-A

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