0

I was previously working on Android Studio 2.1.3 on Windows 10. Now I have migrated to Ubuntu 16.04. When I opened my project from the NTFS drive in Ubuntu Android Studio, It says each and every file is changed in git.

If I check the changed content, it says files are identical. When I tried to check from the external git client, it shows all lines as (-) and same content as (+). I don't understand why this had happened.

Do this has something with the end line character? What can I do now so that it can only show the changed content?

NOTE: This can be identified as a duplicate as for general scenario of line endings in any git repo. But, for specifically Android Studio this can be solved as per my answer.

kirtan403
  • 7,293
  • 6
  • 54
  • 97

2 Answers2

1

Following the answer from another thread on Stack Overflow.

The first step would be to install tofrodos (an utility to convert files between DOS and Unix). In a terminal:

sudo apt-get install tofrodos

Then open a terminal in android project directory:

find . -type f -print0 | xargs -0 dos2unix

The above command will go through the folders and change files to LF format.

Then do the following in your project directory:

git add -uv 

This adds the changes.

Community
  • 1
  • 1
Sarhad Salam
  • 428
  • 3
  • 12
1

To solve this for Android Studio this 2 articles from the IntelliJ website, helped me.

1) https://www.jetbrains.com/help/idea/2016.2/handling-lf-and-crlf-line-endings.html

2) https://www.jetbrains.com/help/idea/2016.2/configuring-line-separators.html

This is what I did to solve it:

Open Terminal and type: git config --global core.autocrlf input

Set the default line endings:

  • In Settings, click Code Style.
  • From the Line separator (for new files) drop-down list, select the desired line separator style: Windows

Change the line separator of the files you have changed/created:

  • Re-Open the files you have created in Ubuntu Android Studio
  • From the status-bar click on the LF (if it is LF) and change it to CRLF.
  • Do this for every file which is in LF (files you have created in Ubuntu Android Studio)

Now, restart Android Studio, And try to commit. You wont see all the files there. If you still see all files, Unstage all files from any external git client and then re-start Android Studio and try to commit. Now, you will see only modified files.

kirtan403
  • 7,293
  • 6
  • 54
  • 97