GitHub 프로젝트를 Eclipse로 가져 오기
GitHub 프로젝트를 가져 왔지만 Eclipse 프로젝트 작업 공간에서 프로젝트를 어떻게 설정합니까?
프로젝트를 체크 아웃하기 전에 GitHub 작업 디렉토리 (c : \ users)를 Eclipse 작업 디렉토리 (c : \ Projects)로 설정해야합니까?
편집 :
내 작업 디렉토리는 이제 c : \ users \ projectname \ .git입니다. 그런 다음 이클립스 "가져 오기"옵션을 사용하여 프로젝트를 가져 오려고합니다. "새 프로젝트 마법사 사용"옵션을 선택하여 가져 오려고하면 소스 코드를 가져 오지 않습니다. "일반 프로젝트로 가져 오기"옵션을 선택하여 가져 오면 소스 코드를 가져 오지만 Eclipse에서 작성된 작성된 프로젝트는 Java가 아닙니다. 계획. "새 프로젝트 마법사 사용"옵션을 선택하고 마법사를 사용하여 새 Java 프로젝트를 작성할 때 코드를 자동으로 가져 오지 않아야합니까?
Alain Beauvois 의 답변 에서 언급했듯이 이제 (Q4 2013)
GitHub에서 URL을 복사하고 메뉴에서 Eclipse에서
File → Import → Git → Projects from Git
Git 저장소가 아직 복제되지 않은 경우 :
원격 프로젝트를 체크 아웃하려면 먼저 저장소를 복제해야합니다.
Eclipse 가져 오기 마법사 (예 :)를 열고 Git File => Import
에서 선택 Git => Projects
하고을 클릭하십시오 Next
.
" URI
"를 선택하고을 클릭하십시오 Next
.
이제 저장소의 위치 및 연결 데이터를 입력해야합니다. URI를 입력하면 일부 필드가 자동으로 채워집니다. 다른 필수 필드를 채우고을 누르십시오 Next
. GitHub를 사용하는 경우 웹 페이지에서 URI를 복사 할 수 있습니다.
복제하려는 모든 지점을 선택하고 다음을 다시 누르십시오.
복제… 버튼을 눌러 Git 리포지토리 복제를위한 다른 마법사를 엽니 다.
원래 답변 (2011 년 7 월)
First, if your "Working Directory" is C:\Users
, that is odd, since it would mean you have cloned the GitHub repo directly within C:\Users (i.e. you have a .git
directory in C:\Users
)
Usually, you would clone a GitHub repo in "any directory of your choice\theGitHubRepoName
".
As described in the EGit user Manual page:
In any case (unless you create a "bare" Repository, but that's not discussed here), the new Repository is essentially a folder on the local hard disk which contains the "working directory" and the metadata folder.
The metadata folder is a dedicated child folder named ".git
" and often referred to as ".git-folder
". It contains the actual repository (i.e. the Commits, the References, the logs and such).The metadata folder is totally transparent to the Git client, while the working directory is used to expose the currently checked out Repository content as files for tools and editors.
Typically, if these files are to be used in Eclipse, they must be imported into the Eclipse workspace in one way or another. In order to do so, the easiest way would be to check in .project files from which the "Import Existing Projects" wizard can create the projects easily. Thus in most cases, the structure of a Repository containing Eclipse projects would look similar to something like this:
See also the Using EGit with Github section.
My working directory is now
c:\users\projectname\.git
You should have the content of that repo checked out in c:\users\projectname
(in other words, you should have more than just the .git
).
So then I try to import the project using the eclipse "import" option.
When I try to import selecting the option "Use the new projects wizard", the source code is not imported.
That is normal.
If I import selecting the option "Import as general project" the source code is imported but the created project created by Eclipse is not a java project.
Again normal.
When selecting the option "Use the new projects wizard" and creating a new java project using the wizard should'nt the code be automatically imported ?
No, that would only create an empty project.
If that project is created in c:\users\projectname
, you can then declare the eisting source directory in that project.
Since it is defined in the same working directory than the Git repo, that project should then appear as "versioned".
You could also use the "Import existing project" option, if your GitHub repo had versioned the .project
and .classpath
file, but that may not be the case here.
With the last ADT, you can import Github project using Eclipse :
File -> Import -> Git -> Projects From Git > URI
Enter the Github repository url
Select the branch
I encountered the same problem, and finally found a way:
- Add or create git repository in git view.
- Click new java project menu, uncheck "use default location", select the git repo location, click finish.
Ecplise Version: Mars.2 Release (4.5.2)
unanswered core problem persists:
My working directory is now c:\users\projectname.git So then I try to import the project using the eclipse "import" option. When I try to import selecting the option "Use the new projects wizard" the source code is not imported, if I import selecting the option "Import as general project" the source code is imported but the created project created by Eclipse is not a java project. When selecting the option "Use the new projects wizard" and creating a new java project using the wizard should'nt the code be automatically imported ?
Yes it should.
It's a bug. Reported here.
Here is a workaround:
- Import as general project
- Notice the imported data is no valid Eclipse project (no build path available)
- Open the
.project
xml file in the project folder in Eclipse. If you can't see this file, see How can I get Eclipse to show .* files?. - Go to
source
tab -
Search for
<natures></natures>
and change it to<natures><nature>org.eclipse.jdt.core.javanature</nature></natures>
and save the file(idea comes from here)
- Right click the
src
folder, go toBuild Path...
and clickUse as Source Folder
After that, you should be able to run & debug the project, and also use team actions via right-click in the package explorer.
If you still have troubles running the project (something like "main class not found"), make sure the <buildSpec>
inside the .project
file is set (as described here):
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
Using the command line is an option, and would remove the need for an Eclipse Plugin. First, create a directory to hold the project.
mkdir myGitRepo
cd myGitRepo
Clone the desired repository in the directory you just created.
git clone https://github.com/JonasHelming/gitTutorial.git
Then open Eclipse and select the directory you created (myGitRepo) as the Eclipse Workspace.
Don't worry that the Project Explorer is empty, Eclipse can't recognize the source files yet.
Lastly, create a new Java project with the exact same name as the project you pulled. In this case, it was 'gitTutorial'.
File -> New -> Java Project
At this point, the project's sub directories should contain the files pulled from Github. Take a look at the following post in my blog for a more detailed explanation.
http://brianredd.com/application/pull-java-project-from-github
It can be done in two ways:
1.Use clone Git
2.You can set it up manually by rearranging folders given in it. make a two separate folder 'src' and 'res' and place appropriate classes and xml file given by library. and then import project from eclipse and make it as library, that's it.
I think you need to create a branch before you can import into your local Eclipse, otherwise, there is an error leading to incapable of importing repository from Github or Bitbucket.
로컬 자식 프로젝트가 일식으로 복제되어 git
관점 에서 볼 수 있지만 package explorer
(작업 공간)에서는 볼 수 없는 경우 다음 단계가 저에게 효과적이었습니다.
git
관점 에서 저장소를 선택하십시오.- 마우스 오른쪽 버튼을 클릭하고 선택
import projects
참고 URL : https://stackoverflow.com/questions/6760115/importing-a-github-project-into-eclipse
'Programing' 카테고리의 다른 글
Google App Engine의 프로젝트 구조 (0) | 2020.07.16 |
---|---|
PHP var_dump와 동등한 Java는 무엇입니까? (0) | 2020.07.16 |
대나무 대. (0) | 2020.07.16 |
JVM의 최대 메모리 사용량을 설정하는 방법은 무엇입니까? (0) | 2020.07.16 |
Mac OS X에서 옵션 키를 누를 때 특수 문자 입력을 비활성화하는 방법은 무엇입니까? (0) | 2020.07.16 |