Existing Java Project into Github - java

I read around to see how to load an existing project into GitHub but I later got really confused. So in the end I did the following:
Created a project which uses the GitHub Repository I have (Library-Tracker) as the location.
Dragged existing Java files into src folder
Committed and pushed
The files showed up on github fine but is this the correct way to load projects onto Github?
Edit: I used eclipse for all of the above

Ye, I think it's fine.
Another one is to create repo using
git init
and then
git remote add origin https://github.com/user/repo.git

Related

Cloning project from Github in Android Studio

I want to clone a project from GitHub, but only some portion of it because the project gets too complicated for me. Is this possible?
Project Link: ExoPlayer
This is the portion what I want to clone: Targated Portion
Note: I have no problem cloning the entire project
download github desktop https://desktop.github.com/
create a folder in your drive named github
open github desktop and go to create new repository
give your repository the name of your project and give the path
of your created folder(drive github).
copy your project from its package where it stored
paste it in the folder(drive github)
go to github desktop and simply Push the origin

Accidentally made my Netbeans Project folder a github repository

I've just finished a java course and a project in which we made a small java application. In the project we used github, but since we're all pretty much beginners to java and github this was a rather confusing process.
Therefore I might have made my NetBeansProjects folder, which is NetBeans' default folder for new projects, a repository to our project on github.
At least what happens is that every time I create a new project in NetBeans, it's automatically connected to our project on github.
I'd really like that my NetBeansProjects folder isn't connected to any remote github projects.
I have tried the git remote remove origin which resets the config by the looks of it but it doesn't solve the problem and any projects I create in NetBeans will still connect to our project on github.
Any suggestions to what might help?
If you don't need to keep track of anything in the Netbeans folder anymore, then you can just erase the .git folder which keeps all the git related data (you will lose everything that hasn't been pushed to github repo as well). The .git directory is hidden, procedure to make it visible (/display & erase it) depends on the OS you are using.
If you want to keep using git, you can add the folders you don't want to have in github repo into .gitignore file.

Git Eclipse import source folder into project

I have a bit of an issue that I can't seem to find a solution to.
I had a project in eclipse that I was working in. I have a remote git repo in which all the source files are backed up to (but it doesn't seem to be the entire project). My project got deleted in eclipse but I had previously had a backup of the entire directory that I had zipped up and emailed to myself a while back which contains the entire project including external libraries etc that I need for the project.
I can import the zipped project into eclipse but obviously the source directory is out of date. I need to be able to pull from my existing repo all the changes I made to my source files. I was able to use the Restore From Local History from the context menu in eclipse which brought in all my changes up until my last push.
Is there a way to re-link this newly create project with my existing repo so all my original commits are available to the new project? Or is there a way to get my source files from my repo into the newly created project. I'm not sure how to proceed and I don't want to make any further changes until I get this resolved.
Any help would be greatly appreciated.
Depending on how you restored the other files, you might run into merge conflicts once you pull from your remote repository. Make sure to make a backup first.
Eclipse:
In the context menu of your Eclipse project, you should see the entries
Team -> Remote -> Configure Fetch from Upstream / Configure Push to Upstream
There you can configure where to fetch from, and where to push to, respectively.
Once you have configured the URI to your remote repo, you might want to use the Dry-Run button to check that it is linked correctly.
Command line:
You can also use the command line to organize your remote repositories.
Navigate to your project and run
git remote
to get a list of your remote repositories.
If that list is empty, you can use
git remote add <remote-name> <your-remote-repo-url>
to add a remote repository. So, e.g.
git remote add origin https://github.com/yourUsername/yourRepo
Then you should be able to pull from your remote as usual.
Alternatively, you could follow this guide to import the remote repository as a new project. This will bring back the source code in its current state in the remote repository.
But you mentioned that the remote repo does not contain the whole project. So you would probably have to add all files manually from your restored project that were not tracked by the git repository.

What is the correct way to have a Java Project with Eclipse on GitHub

I am working on a Java Project with Eclipse which we want to put on GitHub so that it is accessible for the public. But we are not entirly certain what is the correct way to put a Java Project onto GitHub. We have already made a GitHub and uploaded a Java Project. But when checked it out, with EGit, to my computer all the folders are now packages.
Is there any way how this can be avoided? How are you uploading a Java Project to GitHub? Are there any difficulties which we are not aware of right now?
A good example I like to use, is my getting started with selenium project.
This is a Maven enabled Java Project that is hosted on github.
But when checked it out, with EGit, to my computer all the folders are now packages.
This is because of your .classpath. If a source folder is added, (like src/main/java) any subsequent folders will be "packages".
How are you uploading a Java Project to GitHub?
Just as you see in the project above. Upload everything, except binaries, and jar dependencies. (which is why i use Maven)
Are there any difficulties which we are not aware of right now?
Where I work, we use a process in which our projects on github are entire java projects. I've heard that it's bad to upload eclipse specific things like .project, but even individuals who use IntelliJ IDEA, it doesn't seem to be an issue, because they can just upload their .file.
One thing to keep in mind, is your .gitignore. Make sure that /target/classes/* and other java specific compilations are avoided as you want your repo to be only source code. (one thing i DID forget to do on that project above.. will fix ;))
I'd rather not upload .projects or .idea files while uploading projects to VCS system (git or not).
I add these folders to my .gitignore file (wich i upload to VCS)
Regards.

Changing name of project is not reflected on GitHub

I have a java project which I work on using Eclipse ide.
I have renamed my project. This updated my .project file and I pushed it to GitHub.
But GitHub still shows old project name.
Is there any way to change name of project on GitHub?
I am using GitBash on windows to interact with Git
Changing your project name locally does not mean anything to Git or Github, you have to rename your project on Github itself and then update the references to your remote origin at the .git/config file in your local project.

Categories