How to use Submodules with EGit - eclipse

The Eclipse Team Provider for Git works but i do not see any changes for submodules when I use synchronize.
I see changes with the diff on the command line and also with tortoise i see the changes.
So, does anyone know ho to use Git and Eclipse in a way that synchronize and commit works with submodules?

The "Working with Submodules" section shows the submodules in the Git Repositories view:
From there, you have access to two actions:
Selecting the Update Submodule action on a submodule will check out the commit referenced in the parent repository's index for that submodule.
This command will also perform a merge or rebase if that has been configured in the update field for the selected submodule's configuration section in the parent repository's .git/config file.
Selecting the Sync Submodule action on a submodule will update the remote URL used by the submodule from the current value in the .gitmodules file at the root of the working directory of the parent repository.

Related

unable to push source folders from eclipse to GIT

steps I have followed
created a repository
convert to maven project(configure -> convert to maven project)
added facet nature.
created folder structure (src/main/java, src/main/resources, src/test/java, src/test/resources)
After that right click on the project -> GIT bash terminal
git init
git commit -m "first commit"
git remote add origin URL
git push -u origin master
After doing all this when I do a checkout(clone repository -> import projects) I am unable to see the source folder like src/main/java.
screen shots attached
project created with folder structure
folder structure when I did a checkout
A git checkout is used to change the branch you are currently working on. It's probably not what you are willing to do here, is it?
My guess regarding your issue is that your git commit didn't commit your newly created files because they were not tracked when you committed your changes.
When you perform a git init, it basically inits a new empty repository, which means that your files are not tracked by default. You first need to git add them before committing.
My explanation is a bit confusing but I guess that if you first git add your files and then commit, it should work.
EDIT: You don't seem to be talking about git checkout here, but rather cloning. This gives even more sense to my answer, I pretty much think that your files have never been committed because you never added them to the staging area.

source code not pushed to git server via ssh from eclipse

Using Eclipse, I try to push git repository to Git server after making changes in a java file & commit via ssh.
Problem: Only the commit info are pushed to Git server but not the actual java source code.
How can I push java code to Git server from Eclipse?
Following the Egit tutorial on committing changes, make sure you have added the source code which just changed, before committing.
If you don't select Team > Add, the commit won't include those changes.
You must see files in the stages changes part of the commit dialog:
Alternatively you may display untracked files in the Commit dialog and check the Show untracked Files checkbox to select them for inclusion into the commit.
As for a post-receive hook, it is best if you set GIT_DIR in addition of GIT_WORK_TRE. See this example:
#!/bin/sh
unset GIT_INDEX_FILE
export GIT_WORK_TREE=/var/www/example/
export GIT_DIR=/home/mark/test/.git/
git checkout -f

How to commit changes inside a submodule in Eclipse's eGit?

So Eclipse's git plugin - eGit - has been supporting submodules for a while now (they added support in 1.3 release on February 15, 2012, so over a year now). I've just started to use them. I am able to add a submodule without a problem, I can create and checkout a branch inside the submodule for my local patches. I can also create a commit in the submodule.
But how do I update master repository with the pointer to the new commit? When I choose "Update submodule" it rather reverts me back to the original commit that was checked out upon adding the submodule (which isn't surprising when you think what git submodule update does). When I hit "Sync submodule" it doesn't appear to do anything at all.
So is there a way to make the master repo aware of the new commits in the submodule using eGit? I know perfectly well how to do that from the command line, but still I am trying to find out if that is possible from eGit.
Once you have modified a submodule, the Egit status done on the parent repo level should detect that this submodule has changed.
(git status, -- or gitsubmodule status implemented in JGit -- would detect any change in the submodules)
You should be able to commit, in the parent repo, even if no other files (of the parent repo) have changed, because of the "modified" state of the submodule.
That commit, recording a new SHA1 in the .gitmodules file and a special entry in the working tree, will record the new state of that submodule in the parent repo.

How to create default branch with Eclipse?

When I am creating a repository in Git it says "This repository's default branch is empty!"
Earlier I had a master branch and a source button with SSH, HTTP.
So how can I create this default branch, without using the terminal?
When you create a new, empty, git repository you will have an empty default branch until your first commit.
When using EGit, you can create a new git repository from the Git Repositories view. See Creating a Repository. When that's done, I create my workspace projects, uncheck "default location", and specify a directory within my newly created Git repo. There's more of a discussion on creating git repos in relation to a workspace in Considerations for Git Repos.
Thx all but i resolved my issue.
In repository Admin panel just need to check GitHub Pages, it creates "gh-pages" branch and shows a source button with SSH, HTTP.

How do I create a remote git repository in EGit and link it to an existing Eclipse project?

I am using Eclipse Helios and EGit. I am new to Git. I have an existing Eclipse project for an Android app I would like to place in Git. Can someone please share some instructions on how to setup a Git repo on a shared folder, and place the existing project into this git repo using EGit? I have tried a variety of options with no success.
Thanks!
I had the same question (how to do it in Eclipse / eGit), and I just found the answer to the question stated in the title :
either go to Window > Show View > Other... then select Git > Git repositories or click the Git repositories icon in the set of icons in the right
expand the repository to see "Remotes", right click and Create Remote
choose the option : fetch will tell eclipse you're only allowed to read (which is the correct option if you don't want/have the right to push on that repo). then name that remote repository like you want (the first is usually named "origin", but you can have "prod", "test-server", ...)
click on change to specify the uri of the repository. You can paste on the first field the complete uri you would type after "git clone"; if in GitHub you first copy the uri then it might be automatically filled in
"Finish" then "Save and Push" or "Save and Fetch" according to what you chose in 3°
Also, for creating a new project in Eclipse from an existing git repository with eGit, all you have to do is to go in File > Import...and choosing Git/Projects from Git. Then follow the steps
You can do everything from the command line instead:
Do this in the root of the project:
git init
Do the same in the folder where you want your blessed or central repository:
git init --bare
In the local repository, add a readme file and commit it:
echo "testing" > readme
git add readme
git commit -m "initial commit"
Now link and push your changes to the central repository:
git remote add origin //server/share/repodir
git push -u origin master
Hope this gets you started.
You can use egit later if you like, but there is nothing wrong with using git separately.
See http://wiki.eclipse.org/EGit/User_Guide
If you only want one project in your git repo, Team>Share Project will turn that project into a git repo. You can then create another repo on your share, and push your project repo to the shared folder repo.
If you want a repo with multiple projects, your best bet is to create the project in an external location to the workspace. Then you can create the git repo in the folder above your project.