Why .gitignore and .metadata are not getting commited?

Solution for Why .gitignore and .metadata are not getting commited?
is Given Below:

I am developing a flutter app, using bitbucket as the version control. Below is the .gitignore file:

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release

I do git add * and then git commit -m "message" to make the commit. How unfortunate , the .gitignore file never get commited.

When I am trying to do git pull or git pull --rebase, I get the below error

Updating 200df3e..02afe50
error: The following untracked working tree files would be overwritten by merge:
        .gitignore
        .metadata
Please move or remove them before you merge.
Aborting

Browsing the internet, the issue seems to be the .gitignore file and metadata not getting commited. So the pull can’t merge them.

How can I make sure these files are commited?

UPDATE

I followed user ti7’s answer, after the command git stash pop, I got the below message. what does that mean?

On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   ios/Flutter/Debug.xcconfig
        modified:   ios/Flutter/Release.xcconfig

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ios/Podfile

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/[email protected]{0} (799d2e53c1509af435d5d4d589a0ded18d3aad64)

The files probably don’t exist in your working tree, but do exist on the remote

  • add the files explicitly git add .gitignore .metadata
  • stash ’em git stash
  • then merge git pull
  • unstash git stash pop

The problem with git add * is that * is expanded by your shell, but not including .dotfiles