git - 为什么 .gitignore 和 .metadata 没有被提交?

标签 git flutter bitbucket gitignore

我正在开发一个flutter应用程序,使用bitbucket作为版本控制。下面是 .gitignore 文件:

# 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

我执行git add *,然后git commit -m“message”进行提交。多么不幸,.gitignore 文件从未被提交。

当我尝试执行 git pullgit pull --rebase 时,出现以下错误

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

浏览互联网,问题似乎是 .gitignore 文件和 元数据 未提交。所以 pull 无法 merge 它们。

如何确保这些文件已提交?

更新

我按照用户 ti7 的回答,在命令 git stash pop 之后,我收到以下消息。这是什么意思?

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/stash@{0} (799d2e53c1509af435d5d4d589a0ded18d3aad64)

最佳答案

这些文件可能不存在于您的工作树中,但确实存在于远程

  • 显式添加文件 git add .gitignore .metadata
  • stash 它们 git stash
  • 然后 merge git pull
  • unstash git stash pop

git add * 的问题是 * 由您的 shell 扩展,但不包括 .dotfiles

关于git - 为什么 .gitignore 和 .metadata 没有被提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68595431/

相关文章:

github - Git - 同一分支上的多个开发人员

git - 如何从 git 上丢失的提交中恢复代码?

git - 为什么 --autostash 选项不起作用??? (与 git pull --rebase 一起使用)

flutter - 如何使用 flutters video_player 或 Chewie 或 video_viewer 插件播放 m3u8 链接?

flutter 逻辑问题

linux - 是否可以使用 Git 扩展或 Git GUI 来管理远程 linux ftp 服务器上的文件,如本地存储库

git - bitbake git fetcher 失败

相当于 url.insteadof 的 Git 子模块

flutter - Flutter/Dart-动态字体大小以适合Card

python - 推送到 Git 存储库时如何设置自动部署到 AppEngine