The key lies in when you create the project in eclipse.
First step, you create the Java project in eclipse. Right click on the project and choose Team > Share>Git.
N.B: Eclipse will give you a warning about putting git repositories in your workspace. So when you create your project, set your project directory outside the default workspace.

Related Posts:
- ‘cannot open git-upload-pack’ error in Eclipse when cloning or pushing git repository
- How do I set up Eclipse/EGit with GitHub?
- How to solve could not create the virtual machine error of Java Virtual Machine Launcher?
- How to solve could not create the virtual machine error of Java Virtual Machine Launcher?
- Editor does not contain a main type
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- Eclipse: Enable autocomplete / content assist
- java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing
- “insufficient memory for the Java Runtime Environment ” message in eclipse
- Control an Arduino with Java
- How do I resolve the “java.net.BindException: Address already in use: JVM_Bind” error?
- Opening JSF Facelets page shows “This XML file does not appear to have any style information associated with it.”
- web.xml is missing and
is set to true - The program can’t start because cygwin1.dll is missing… in Eclipse CDT
- Eclipse C++ : “Program “g++” not found in PATH”
- Unbound classpath container in Eclipse
- “Server Tomcat v7.0 Server at localhost failed to start” without stack trace while it works in terminal
- java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
- “Server Tomcat v7.0 Server at localhost failed to start” without stack trace while it works in terminal
- web.xml is missing and
is set to true – web.xml is there and can’t edit deployment assembly - eclipse won’t start – no java virtual machine was found
- How to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven Builds
- Eclipse returns error message “Java was started but returned exit code = 1”
- Ant “JAVA_HOME does not point to the JDK” – but it does
- Program “make” not found in PATH
- Eclipse internal error while initializing Java tooling
- web.xml is missing and
is set to true - How to clear console in Java – Eclipse
- Eclipse keyboard shortcut to indent source code to the left?
- eclipse for chrome?
- Can eclipse be configured to automatically fix missing Imports?
- Program “make” not found in PATH
- Importing Maven project into Eclipse
- How to show the Project Explorer window in Eclipse?
- Avoiding “resource is out of sync with the filesystem”
- Eclipse Mars vs Luna
- How to open an existing project in Eclipse?
- Importing a GitHub project into Eclipse
- CodePro Analytix: Where to find the plugin
- Eclipse EGit Checkout conflict with files: – EGit doesn’t want to continue
- How to open Console window in Eclipse?
- Some projects cannot be imported because they already exist in the workspace error in Eclipse
- Java error no lwjgl64 in path?
- Why am I seeing “TypeError: string indices must be integers”?
- How to uninstall Eclipse?
- How can I switch to another branch in git?
- Why am I seeing “TypeError: string indices must be integers”?
- Eclipse/Maven error: “No compiler is provided in this environment”
- GitHub: Permission denied (publickey). fatal: Could not read from remote repository
- Can’t start Eclipse – Java was started but returned exit code=13
- Can’t start Eclipse – Java was started but returned exit code=13
- git error: failed to push some refs to remote
- GitHub – error: failed to push some refs to ‘[email protected]:myrepo.git’
- Eclipse IDE for Java – Full Dark Theme
- Is there a way to convert all comments into javadoc comments? [Eclipse/Java]
- git – remote add origin vs remote set-url origin
- GitHub Error Message – Permission denied (publickey)
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1
- Updating a local repository with changes from a GitHub repository
- Git push results in “Authentication Failed”
- Git error: “Please make sure you have the correct access rights and the repository exists”
- Failed to write core dump. minidumps are not enabled by default on client version of windows
- github changes not staged for commit
- Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists
- Git push results in “Authentication Failed”
- Download single files from GitHub
- How to uninstall Eclipse?
- How to draw checkbox or tick mark in GitHub Markdown table?
- How do I pull my project from github?
- Untrack files from git temporarily
- Difference between Git and GitHub
- Editor does not contain a main type in Eclipse [duplicate]
- Is it safe to download code from GitHub?
- How to draw checkbox or tick mark in GitHub Markdown table?
- “Error occurred during initialization of VM; Could not reserve enough space for object heap” using -Xmx3G
- How to solve SSL certificate: self signed certificate when cloning repo from github?
- Editor does not contain a main type in Eclipse [duplicate]
- How to upload folders on GitHub
- Change GitHub Account username
- undefined reference to `WinMain@16′
- How to find my GitHub username so that I can be found via the URL?
- Git, fatal: The remote end hung up unexpectedly
- Git – remote: Repository not found
- Pushing to Git returning Error Code 403 fatal: HTTP request failed
- github website publish cannot publish unborn HEAD
- JRE Missing when installing eclipse
- fatal: The current branch master has no upstream branch
- Git master branch has no upstream branch
- Superscript in markdown (Github flavored)?
- Create a tag in a GitHub repository
- How to fix HTTP 404 on Github Pages?
- Git: Could not resolve host github.com error while cloning remote repository in git
- How to pull a specific branch from Github
- A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1
- make: g++: Command not found
- How can I determine the URL that a local Git repository was originally cloned from?
- GitHub: invalid username or password
- “Cannot publish, unborn head” error message