Pratham Patel
Pratham Patel

Reputation: 67

Duplicate files created when I import a project from git

I have created a repo on github as my final year project for tracking changes and also so that I have a MacBook for being mobile and also work on my workstation when I'm home;

I created an empty repo on github and then pushed the android project from my workstation to github. Worked on it for a while and got basic things running and pushed code a few minutes ago from writing this post and cloned the project on my macbook. I selected the project on my macbook and a few seconds later when Android Studio was done "indexing" files, I saw there was MainActivity2.kt and activity_main2.xml (which I didn't create). I freaked out and did a git status which showed that the local repo had no changes.

I then closed Android Studio on my mac, deleted the aforementioned local repo and opened Android Studio (as a safe measure, idk why I did it tho) and also removed the project from recents tab. I cloned the repo once again and now I have all (all that I know of - as I'm new to android studio + kotlin) .kt and .xml files with their <file-name-goes-here>2.kt and <file-name-goes-here>2.xml;

I did a git status again, it showed me this. I don't know why duplicates were created.

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

Also, I just noticed there are a few files with a third copy as well (colors 3.xml, strings 3.xml and themes 3.xml)

Here's the link to my github repo in case there is something wrong with the contents of my code, but I hope it's to do with Android Studio.

Upvotes: 4

Views: 800

Answers (1)

Ankush Chavan
Ankush Chavan

Reputation: 1214

The code and file structure in your GitHub repository seems to be correct. I think this issue is caused because of iCloud syncing. I have two solutions.

Solution 1:

Check if your mac is storing project directory and files on iCloud. This issue is mostly caused because iCloud keep on syncing the files and that's why somehow the duplicate files are get created with incremental numbers.

Check if "Desktop & Document Folders" are storing documents and data on iCloud. More specifically check if iCloud is storing your project folder. If yes then uncheck this option.

Solution 2:

Another solution would be to add the .nosync extension to your project directory.

For eg. If your project directory name is MyProject then rename it to MyProject.nosync.

Upvotes: 5

Related Questions