10

I am trying to add gradle.properties like rest but still changes that files changes are showing in git status.

Is there any other way to add files in git-ignore using android studio.

Nikunj
  • 3,937
  • 19
  • 33
Hitesh Matnani
  • 309
  • 1
  • 5
  • 20

3 Answers3

29

You should use git rm to untrack the gradle.properties file first.

git rm --cached gradle.properties
git commit -m "Remove gradle.properties"

Then add the following line to your project .gitignore file

gradle.properties

Commit and push that and any new changes to this file should not be tracked.

Mostafa Gazar
  • 2,487
  • 18
  • 23
3

It seems you already added this file to repo, and then you want to ignore it. In this case your file exists in Index/Staging area so git is showing it into changed file list.

So you need to remove this file from Index/Staging area, to do so you just need to clean git cache. Execute below command

git rm --cached gradle.properties

Read more details about Untrack files already added to git repository based on .gitignore

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
0

Simplest way use gitignore plugin and just right click the file which you want to hide and and you'll see add to gitignore option, select it and its done.

Ashish Sharma
  • 566
  • 5
  • 20