For my team, we have our code on a laptop and my personal pc.
Ive noticed that each time i pull new code and build on whichever computer, i get new .classpath and .jar files made
To me it seems that this is because of small differences in the computers software.
Obviously, i need to ignore these but when i add .jar and .classpath to my gitignore, it doesnt work.
my gitignore file is like this(-- show beginning and end)
Itâs likely because your git repository is already tracking those files. When you edit your .gitignore file, the new .gitignore file will not ignore any already tracked files.
That only ignores files literally named â.jarâ and â.classpathâ. If you want to ignore all files with .jar and .classpath extensions, you need to use asterisks:
I suggest using gitignore.io. Just enter the operating system(s), programming language(s), IDE(s) etc. you use, and then paste the output in your .gitignore file.
Hey, none of what anyone has said has worked somehow, so Iâm thinking of just ignoring anything that isnt in the src folder
Sounds bad but could someone write me a quick .gitignore that would do this, only track things in the src folder. I have this but its not workingâŚ
OP, I think you are going to have to be a bit more specific about what is not working. I strongly suspect the above post contains your answer: adding patterns to the gitignore does not impact files already being tracked.
As far as I know, The most recent example of gitignore you posted likely will not work either, as it would exclude Gradle or eclipse files required to define the project.
Ok so nothing is working so Iâve decided to start a new project. Once I start it and copy the code files, i make it into a repo using eclipse, got that. Make the initial commit, no problem.
After that, what do I add to the .gitignore so that it only tracks things in the src folder, and if that isnt possible , to not track .jar ,.class or .classpath files
I know the answers are simple, but they arent working, so what can I do?
Orr, the problem is when I pull and push from different computers, is that giving me my problem? To me it shouldnt be, because a gitignore should just ignore those types of files! Thanks!
What files are part of the initial commit? Is it just source code and project files, or does it include the .jar files?
Background facts to keep in mind as you troubleshoot:
â*.<extension>â is the proper syntax for excluding all files with a certain extension.
The tracking of file changes occurs at add/commit time, not on push or pull. As long as files get tracked when the commit is created, all subsequent pushes and pulls will by default include those files.
Ok so what I did was restart my project, manually start the repo from the git shell. Once i had everything tracked, I commited and pushed and then deleted the repo from my computer lol so that i could then clone it from github desktop to no longer have to use the shell from everything( i deleted because for some reason âfindingâ existing repos from github desktop never worked.
From here , i cloned on the laptop , ran and commited and pushed until i could run on both computers without having any new files.
From here, i did git rm --cached *.jar, commited and pushed, then changed the gitignore accordingly, commited and pushed and voila, no longer getting those pesky .jar files
Thanks everyone for the help, during my troubleshooting i learned more than i ever had about git, and the importance of .class and .classpath files!
FYI if youâre in the bucket of starting from scratch, hereâs the procedure I generally use. Iâm not very well versed in github desktop, just git command line.
Create initial set of files - from template, copied in, etc. Get a basic build up and running.
Add a .gitignore . Add file patterns that should be ignored - .jar/.class in your case, maybe others depending on the IDE/Language.
Open a git bash in the root of the folder structure
Inspect the output of git status. Confirm no temporary build files, or anything you donât want archived is staged for commit. Undo staging and edit the .gitignore as needed.
git commit -m âInitial contentâ
git push origin
This should get one initial commit out on your github server repo with no undesired build files.
FYI - for the procedure you listed above - one downside to it is that your early commit(s) will have the build files in them. This means that git stores data in its backend to recreate them if needed. If youâre not checking out those initial commits, and the total size of the .jar/.classpath files isnât too large, this isnât all that bad, and I wouldnât worry about it. However, if the files happened to be massive, they would slow down clone (and maybe push/pull) operations (even though youâre never actually using them on the latest). Again for FRC purposes this is probably totally not a concern at all, I just come from an industry background where we care about such scalability matters.