DraxDomax
DraxDomax

Reputation: 1068

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!

Upvotes: 1

Views: 110

Answers (2)

Ben Allal
Ben Allal

Reputation: 27

the command is "git add . " ('.' enstead of '*') and no need for -A

Upvotes: 0

VonC
VonC

Reputation: 1329822

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".

Upvotes: 3

Related Questions