After trying from using the following:
The classes still get pushed up to bitbucket repository.
Did I miss out anything because I checked around and almost everyone said it is to be done like that.
Do you want to ignore all files with the extension .classes in your repo? Or files with the extension .classes from a certain directory of the repo?
Using *.classes should exclude all files with this extension, but I'm not sure what you are attempting to do with the pattern *.classes/folderName
Could you please clarify what you are trying to achieve?
Please keep in mind that if you had already committed in this repo any files with this extension before adding the .gitignore to the repository, these specific files will continue to be tracked. In this case, you will need to remove these files from the repo's history by rewriting history (I can share more details if you like) and then make sure that your repo has a .gitignore with the correct pattern.
I have changed it to *.classes already.
Now, I hope you could iron out my doubts regarding setting a global git ignore.
After watching a you tube video, I have put the git ignore at the C:\Users
Then, I did a git bash on the directory where my cloned repo branch lies :
git config --global core.excludefile ~/.gitignore - global.
Now, things get abit complicated when I realised that someone has checked in another change upstream.
So, I did a reset HEAD follows by a git stash to keep my changes.
After that, all the conflicts appear and I am lost.
I did a quick and dirty job by cloning another one.
However, after that, I am not able to make the project folder to git ignore the .classes again, even though I did all those above steps.
My question is if I still have something in the BitBucket repo, whatever I did, the .classes will still be uploaded is it ?
How do I make it such that my .classes won't be able to commit or can the administrator able to do some setting such that people won't be able to pull anything that has .classes inside ?
And did I miss out any steps that my global git ignore doesn't work ?
Location of .gitignore
You mentioned that you put the .gitignore file in C:\Users. However, the git config command uses ~/.gitignore and ~ is your home directory, which is normally C:\Users\MyUser on Windows (MyUser should be the name of your user on your computer).
I would suggest moving the .gitignore file in C:\Users\MyUser, and then from Git Bash you can execute this command
git config --global core.excludefile ~/.gitignore
Afterwards, check if the file is added by running the command
git config --global core.excludefile
Please note the following:
Setting a .gitignore globally on your machine prevents you from adding files specified in .gitignore in your repos.
It does not prevent your teammates from adding these files to their local clone.
In order to do that, you can do either of the following:
1. Either ask your teammate to set the same .gitignore globally on the machine they are working from
2. Or you add and commit the .gitignore in the repo. This way, when someone else takes a fresh clone of the repo, they'll have the .gitignore of this repo locally.
Removing committed files from the repo's history
If there are existing .classes in the repo (that were added before the .gitignore), you will need to remove them from the repo's history with a tool like BFG:
BFG has an option --delete-files (see documentation), so you can use it to delete all .classes files from the repo.
Please note that BFG rewrites history, which means that commit hashes will change. It's good to communicate this to your team so there are no surprises.
I also strongly recommend taking a backup of the repo (a clone with the --mirror flag, other than the one where you execute BFG), in case you want to revert the repo to the prior state.
In summary, my suggestions would be:
It will be pushed
But these files will not be tracked via git, that's the whole purpose
To learn more about how .gitignore works go through the doc here
OK. I read in the tutorial that we can set it globally but it is using touch commands but I am using Windows 10.
So, I'd like to confirm is it done this way :
1. I will put *.classes/folderName in git ignore
2. then I do the following command
git config --global core.excludesFile ~/.gitignore
3.do the normal git add fileName
the classes/folderName won't get push up
Secondly, I'd like to clarify what do you mean by it won't be tracked and also if I do git config at that cloned project folder, will it just apply to that project only ? How do i make it ignore .classes/folderName throughout all the projects locally and it won't get push up to the repository.
Hope you could let me know.