Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to gitignore a particular Java file or any folder or any XML file in Android project?

I have a project in Bitbucket and I want to give access to one of my intern. I want to ignore certain Java files and certain file inside debug folder.

I have tried using the way, adding this line in my gitignore file:

/app/src/main/java/com/example/amanv/emulatordetection/NewActivity.class

However, this didn't work out.

I also tried:

/NewActivity.class

didn't work out too.

How can I do that?

like image 548
Aman Verma Avatar asked Dec 17 '22 19:12

Aman Verma


1 Answers

You can not ignore those files that you have previously committed, for that you have to remove those files from your git.

  1. To do that first go to your file directory.

  2. Now type this command to remove the file from your git.

    git rm --cached [filename]

  3. Now the file has been removed from your branch, and now you have to add the file name in your .gitignore file.

    filename.java (Remember that the activity extension should be in java.)

  4. After that, add the files to the branch and then commit them. Then finally, push and you will see the files are ignored.

    Check how i did...

like image 151
Saharsh Pandey Avatar answered Dec 21 '22 11:12

Saharsh Pandey