今天提交代码出现以下现象:
admin:ios-hybird-flutter Red$ git add .
admin:ios-hybird-flutter Red$ git st
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: FlutterBoostDemo/.gitignore
new file: FlutterBoostDemo/.metadata
new file: FlutterBoostDemo/FlutterBoostDemo.iml
new file: FlutterBoostDemo/FlutterBoostDemo_android.iml
new file: FlutterBoostDemo/README.md
new file: FlutterBoostDemo/lib/FirstPage.dart
new file: FlutterBoostDemo/lib/main.dart
new file: FlutterBoostDemo/pubspec.lock
new file: FlutterBoostDemo/pubspec.yaml
new file: FlutterBoostDemo/test/widget_test.dart
new file: SwiftDemo
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)
(commit or discard the untracked or modified content in submodules)
modified: SwiftDemo (modified content, untracked content)
问题:
modified: SwiftDemo (modified content, untracked content)
SwiftDemo目录没有被跟踪,尝试几次都没有add上去,从SourceTree上看SwiftDemo只是一个空目录,目录下的文件没有加进去。
解决办法:
SwiftDemo目录里有一个.git目录,就是说SwiftDemo本身也是一个代码库。
admin:SwiftDemo Red$ rm -rf .git
删除.git目录后,git add . 还是不行。
最后把SwiftDemo目录移动到其它目录,再移回去,git add . 正常。