I am using eclipse java as an editor and would like to use the .gitignore to exclude the build folder for the project. This is what I have currently written in my .gitignore. The syntax seems to be right; I used the git documentation but I may have interpreted it wrong.
#ignoring the files within the build folder
/build/
build/**
I'm using a brand new repo so I shouldn't have any problems with already logged files in the repo.
I am trying to get git to ignore the build folder in the project file using a .gitignore. The ignore file didn't work. What could be a solution?
The way the .gitignore is written, this file needs to be in the same subfolder as the build folder, the file being ignored.
Related
Using eGit...
When I perform the initial Commit and Push from Eclipse, a new directory appears in the remote repo. Inside that directory is the root of the project directory. It makes a big mess because when someone clones it (again using eGit) the src folder is munged into a name containing then project folder name, which mucks up the package references in the class files.
eGit assumes you don't want an entire git repository for a single workspace project. Doing so would be wasteful and cumbersome for almost anything nontrivial. https://wiki.eclipse.org/EGit/User_Guide#Implications
You also didn't commit the .classpath file, which would have indicated what the source folders were.
There is a folder in a Git repo which holds a bunch of sql scripts but the folder is not part of any project. When I try to create a folder in Eclipse it seems to require that I specify an existing project for it to be a subfolder of. Is that always required or can a folder exist at the same level as the projects, with no project for it to be under?
Everything in an Eclipse workspace must be in a project. Folders cannot be at the same level as a project.
I couldn't find a question that similar to mine but the point I'm asking is where do I run git init? Do I run it in the src folder where my code is or in the project folder which contain the src folder and a bin folder? I'm working with eclipse and gitBash. Hope this is enough info.
What do you mean by builded project? Are you referring to .classpath, .project, .settings
When you create a repo, you need to include anything needed to actually build the project.
That include the src/ folder, but also other configuration files.
Those can include the .project (if it has only relative paths, easily reused by others), and the .classpath: see ".classpath and .project - check into version control or not?".
The settings/ folder can also be included 5see "Which eclipse files belong under Version Control", but not the .metadata/ subfolder.
It even can include settings for other IDEs like IntelliJ IDEA, if other contributors are using that tool.
It would not include the bin/ folder, typically added in a .gitignore, because its content is regenerated on demand (built).
Run it in the Project folder.
src folder contains the code files mostly. But supporting resources may be included in the other folders. And you will need to add everything to git without which project may have problem running.
Android studio is not pushing java files to github. I found that it only pushed the src folder with the res (layouts and xml docs) folder. I tried adding the java folder to it (right click, add, then commit directory, and push), but it still does not push the java files to git.
Used this setup:
https://www.londonappdeveloper.com/how-to-use-git-hub-with-android-studio/
.gitignore:
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
When I right click on the Main folder (which holds the java files) and select commit directory, I get the following error:
Error:On branch master
nothing to commit, working directory clean
during executing git commit --only -F C:\Users\mmm\AppData\Local\Temp\git-commit-msg-999645.txt -- MainActivity.java
Did it through gitbash following the instructions here:
https://help.github.com/articles/adding-a-file-to-a-repository-from-the-command-line/
Right clicked on the main folder (containing the java files) and selected gitbash.
I ran into this issue recently. If your .gitignore looks good, you may want to check Git (local git repository) first and see if the .java files show up there.
The folder (/apps/src/main/java/myproject/bleh) where .java files were stored was flagged as "* Git Repository (subproject)" by Git and that was a consequence of a hidden .git file stored there.
Fixed it by deleting that .git file and adding the files to the repository.
I am working following a set of java swing tutorials, each is an Eclipse project, keep them in a workspace. I init a git repository in the workspace folder (mac), and upload to github. When I download this folder in another computer (linux), the projects are not recognized as such, and opening/importing in Eclipse fails. Says: 'Folder not recognized as project'. What is the best way to handle a collection of projects in git?
If you want to have all of your Eclipse project data across your machines, you will have to add the following files/folders to Git:
.classpath
.project
.settings (folder)
Make sure that these are not ignored in either your local or globale .gitignore files.
Ignore things like the bin and target folders, since they contain the compiled classes and shouldn't be added to Git.
Regarding the failed import: as #nwinkler writes, Eclipse looks for the .project and .classpath files so you need to add them (and the .settings directory) to your git repository.
Regarding .gitignore, I typically put the workspace stuff there (and then do import existing projects in eclipse after cloning):
That is,
.metadata/.plugins
.metadata/.lock
.metadata/.log
and then for each project, the bin folder
project_dir/bin
and any other generated files