Reputation: 3325
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?
Upvotes: 4
Views: 6701
Reputation: 160
You can not ignore those files that you have previously committed, for that you have to remove those files from your git.
To do that first go to your file directory.
Now type this command to remove the file from your git.
git rm --cached [filename]
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.)
After that, add the files to the branch and then commit them. Then finally, push and you will see the files are ignored.
Upvotes: 7
Reputation: 76
Please mind, that the path of files you want to ignore with a .gitignore
file are relative to the path of your .gitignore
file in your repo.
so:
/NewActivity.class
means: ignore the file NewActivity.class in the same directory as .gitignore and not in subdirectories
NewActivity.class
means: ignore the file NewActivity.class in the same directory as .gitignore and in all subdirectories
If you want to use:
/app/src/main/java/com/example/amanv/emulatordetection/NewActivity.class
then your .gitignore file has to be located in a parent direcory of app, which has to be part of your repository of course.
Upvotes: 3
Reputation: 5705
I think the extension should be .java instead of .class.
So instead of this
/app/src/main/java/com/example/amanv/emulatordetection/NewActivity.class
It should be this
/app/src/main/java/com/example/amanv/emulatordetection/NewActivity.java
Upvotes: 1