Git on top of SVN - java

I'm trying to use Eclipse with Git pointing to a SVN directory. (My workplace doesn't trust Git yet.)
I've cloned the SVN repository and now have a Git repository with the SVN data.
I can associate Eclipse with the git repository but I don't know how to import the source code with my git workspace.
My question is how to set up Eclipse so that I have a git workspace that looks at my code and track it in my git repository. I can't see the source code in the git repository and there is no project to import.
The projects are java built with ant.

Don't exactly know whether it will be helpful to you, but I recently looked up a few things about migrating into git from svn and maybe these to articles are helpful to you too:
http://john.albin.net/git/convert-subversion-to-git
https://www.atlassian.com/git/tutorials/migrating-overview/

Related

To commit locally in Intellij, do you install git.exe

I am completely new to Java, Intellij and Eclipse.
Recently, I was assigned to
Set up local Git repository.
Commit to Git repository locally.
Set up a remote Git repository on Github and push it.
In Eclipse, I do the following easily
Set up a Gradle project.
Modify a Library.java file under the directory of src/main/java.
Open Gradle Task and Gradle application thru "show view"
Press run under "application".
Configure Git repository.
So after some Googling, it seems that to start a local repository in Intellij, I have to create Git repository under the "VCS" tab.
However, Intellij said I need git.exe.
So my question is, do I need to download git.exe?
If yes, why doesn't eclipse's gradle project require git.exe?
And, to create a local repository and share it to Github, do I need a gradle project in Intellij?
Eclipes uses JGit, enbaded git, so you can run it without installing a git.
However Intellij haven't a build in git then you have to install it and give Intellij the path for it. (That's why he asked for the path to git.exe).
Go to https://git-scm.com/ and download it.
for github, you just need to config the remotes.
if you got already git ( you already did git init)
then just
git remote add origin https://github.com/*user*/*project-name*.git
and then push.
VCS tab on Intellij means "Version Control System" which gives you options to interact with a VCS tool such as Github, which acts as the repository for your code base. In the "terminal" view on Intellij, you can then use your standard Github commands, so you could use git clone (url from Github) -b (branchname) to pull down your code for the first time. And yes you will need to download git.exe but refer to documentation for full steps.
Intellij and Eclipse are both IDE's, so having used both I would recommend using Intellij but everyone has their own personal preference.
For future usage, here's the basic commands to push to GH as you require:
git status (to check the files you've changed)
git add * (to add all files amended) or git add (filepath)
git commit -m "Message to commit"
git push origin (branchname)
First thing first.
Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people.
Read more in what is git?
When you understand it, it is obvious that you need to install git locally on the computer.
IntelliJ
Intellij has a plugin helps you working with git.
If you read carefully here, you'll see that you need to download and install git before using the IntelliJ plugin.
Eclipse
Eclipse on the other hand uses JGit, a pure java library implementing git version control system.
The Eclipse Git plugin that is called EGit, is using JGit. Which means that you do not actually need to install git in this case.
Since you are completely new with Java, IntelliJ and Eclipse let my give you a good rule of thumb.
If you are working with java and git it is recommended that they will be installed in your computer properly.
IntelliJ and Eclipse are just IDEs with them you can work on your project.
In a properly configured project, you can work either with IntelliJ or Eclipse. It doesn't really matter.
You should not be dependent on any of these IDEs.

No projects found while importing project from GIT

i am facing problem in importing project from github i.e,remote repository.it is giving no project found.and found the reason i should push .project and .classpath files also then only it will recognise the java project.but how to push them.
and i have 1more question
can i push more than 1 project into the remote repository.
i used following commands to push into the repository
git add .
git commit -m "intial commit"
git remote add swathi "https://github.com/swathiananthula/samplerepo.git"
git push swathi master
can anyone help me?
how can I import the project successfully into STS.
Remove .project and .settings entries (or any project config) from the .gitignore file and use git add . and git push.
The next time someone clones your repository they would be able to import it as a project.
Just note that though if you check in project files, make sure you don't have machine specific entries in your project settings as it will differ for each developer. This includes any classpath entries with full paths etc.
For your initial question; yes you can have multiple projects in one repository, though many would not recommend it.

Eclipse setup for git project

There are quite a few questions on this topic, but there are no satisfactory answers unitl now, e.g this.
I'm using Eclipse Kepler (20130529-2219), with ME2 (1.4.0.20130601-0317) and Eclipse Git Team Provider (Java implementation of GIT 3.0.0.201306040240-rc3). So I started with great expectations after reading how great git is.
Firstly, I opened an existing project and removed all the .svn rubbish and commited it to a local git repository. Perfect - now it is time to push the files to a remote repository. After having some problems creating the known_hosts file on Windows the push was successful.
Now the problems started: I wanted to pull changes for the repository, but "... not configured for pull". OK, here it was discussed that this is a common issue, and you have to delete the project and then reimport it from a remote server to allow pulling.
Hence, I set up everything again and pulled the project. Until now I was always told that .project files should not be commit to version control, therefore I didn't include them. The "import -> import from git -> local"-menu does not recognize the files in the repo as a Java project. I can therefore only import the project as a general project or use the project wizzard and set up a new Maven project, which is stupid because all information already exists in the POM.xml. If I do a plain project import, Eclipse does not know that it is a Java or Maven project and throws tonnes of errors.
Question (skip detailed problem): Is there some less awkward way to import a Maven and Java project from a remote git repo when no .project file exists?
Easiest solution: do include the .project (as in this answer) in your git repo.
And do include also the .classpath, since you now can reference relative paths in it, instead of absolute path: see ".classpath and .project - check into version control or not?"
I found an alternative to keep .project file out of Git version control. As you said the pom.xml file should be enough for IDEs to figure out that a maven project it´s in place (and it is).
Let's say you have pushed your project into Git (without .project file) and now you want to import that project into Eclipse.
Make sure you have the Git repo added into Git perspective
Go to J2EE Perspective and double click on an empty space on Navigation View. Import -> Existing Maven Projects
Browse to your Git repo location and voila! Eclipse should catch all pom.xml files and determinate they are independent Maven projects
In my case this worked to pull multiple projects located at one same Git repo, each of them only storing pom.xml file (and no .project at all)

How to add eclipse project to existing git repo?

I already have an existing project in Eclipse that I want to add to my team's github repo. The github repo is empty right now. What's the best way to add this project to our github repo? I was thinking of git cloneing our repo into the workspace folder (parent to the project in question) and then adding the project files using git add, then pushing the changes. Would that work, or is there a better way to do this (perhaps with EGit)?
You have to add a remote to the project, and then push to it.
For example, you can do (from inside the project directory)
git init # if you haven't already
git remote add origin ssh://git#github.com:.....
git push -u origin master
there should be a way to do that from the eclipse plugin too, but I find it easiear to do it from the command line.. :)
By the way, remember to add all the IDE-specific files to .gitignore, to avoid pushing garbage to the world: they usually are .project, .classpath and directories like bin/*,.settings/* ...

What does it mean share project in STS?

I have imported project with Maven. But Subclipse didn't recognize that project already in SVN (I don't see pictogram barrel). For team in context menu I see 2 options:
Apply path
Share project
Which one I must select? In SVN repository there is already project made by other persons.
And I also made checkout by Tortoise. So I need only to recognize SVN local repository by STS.
Sharing the project should make it detect that .svn directories already exist, and should propose you to keep these files and use the information they contain to establish the SVN configuration of the project.
svn is a versionmanagement system. if you got old code and someone released a newer version you can apply a patch. you can share your project on cvs svn and git. like github or google project.
you need to go to new svn repoository and select the one of your project. then you can checkout project as new project. maven is for dependencies, not for code manipulation

Categories