Pra*_*tel 4 git android android-studio
我在 github 上创建了一个存储库,作为我最后一年的项目来跟踪更改,这样我就可以拥有一台可以移动的 MacBook,并且当我在家时也可以在我的工作站上工作;
我在 github 上创建了一个空的存储库,然后将 android 项目从我的工作站推送到 github。工作了一段时间,让基本的东西运行起来,并在几分钟前写完这篇文章后推送了代码,并在我的 MacBook 上克隆了该项目。我在我的 MacBook 上选择了该项目,几秒钟后,当 Android Studio 完成“索引”文件时,我看到有MainActivity2.kt和activity_main2.xml(我没有创建)。我吓坏了,做了一个git status结果显示本地仓库没有任何变化。
然后,我关闭了 Mac 上的 Android Studio,删除了上述本地存储库并打开了 Android Studio(作为安全措施,我不知道我为什么这样做),并从“最近”选项卡中删除了该项目。我再次克隆了该存储库,现在我拥有了所有(我所知道的所有 - 因为我是 android studio + kotlin 的新手).kt 和 .xml 文件以及它们<file-name-goes-here>2.kt的<file-name-goes-here>2.xml;
我再次执行了 git status,它向我展示了这一点。我不知道为什么会创建重复项。
On branch main
Your branch is up to date with 'origin/main'.
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: .idea/gradle.xml
Untracked files:
(use "git add <file>..." to include in what will be committed)
app/src/androidTest/java/com/kinkykeys/countmein/ExampleInstrumentedTest 3.kt
app/src/main/AndroidManifest 2.xml
app/src/main/java/com/kinkykeys/countmein/MainActivity 2.kt
app/src/main/java/com/kinkykeys/countmein/disaster_forecast 2.kt
app/src/main/java/com/kinkykeys/countmein/home 2.kt
app/src/main/java/com/kinkykeys/countmein/scan 2.kt
app/src/main/res/drawable-v24/ic_launcher_foreground 3.xml
app/src/main/res/drawable/ic_launcher_background 3.xml
app/src/main/res/layout/activity_main 2.xml
app/src/main/res/layout/disaster_forecast 2.xml
app/src/main/res/layout/home 2.xml
app/src/main/res/layout/scan 2.xml
app/src/main/res/mipmap-anydpi-v26/ic_launcher 3.xml
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round 3.xml
app/src/main/res/mipmap-hdpi/ic_launcher 3.png
app/src/main/res/mipmap-hdpi/ic_launcher_round 3.png
app/src/main/res/mipmap-mdpi/ic_launcher 3.png
app/src/main/res/mipmap-mdpi/ic_launcher_round 3.png
app/src/main/res/mipmap-xhdpi/ic_launcher 3.png
app/src/main/res/mipmap-xhdpi/ic_launcher_round 3.png
app/src/main/res/mipmap-xxhdpi/ic_launcher 3.png
app/src/main/res/mipmap-xxhdpi/ic_launcher_round 3.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher 3.png
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round 3.png
app/src/main/res/values-night/themes 3.xml
app/src/main/res/values/colors 3.xml
app/src/main/res/values/strings 3.xml
app/src/main/res/values/themes 3.xml
app/src/test/java/com/kinkykeys/countmein/ExampleUnitTest 3.kt
no changes were added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
另外,我刚刚注意到还有一些文件还有第三个副本(colors 3.xml、strings 3.xml和themes 3.xml)
这是我的 github 存储库的链接,以防我的代码内容有问题,但我希望它与 Android Studio 有关。
GitHub 存储库中的代码和文件结构似乎是正确的。我认为这个问题是由于 iCloud 同步引起的。我有两个解决方案。
解决方案一:
检查您的 Mac 是否在 iCloud 上存储项目目录和文件。这个问题主要是因为 iCloud 不断同步文件而引起的,这就是为什么以某种方式使用增量数字创建重复文件的原因。
检查“桌面和文档文件夹”是否在 iCloud 上存储文档和数据。更具体地说,检查 iCloud 是否存储了您的项目文件夹。如果是,则取消选中此选项。
解决方案2:
另一个解决方案是将.nosync扩展添加到项目目录中。
例如。如果您的项目目录名称是,MyProject则将其重命名为MyProject.nosync.