Eclipse neon "no staged files" error - eclipse

I am using Eclipse Neon for Github, to be able to push changes.
I already have a Github account and made a specific repository just for trying, but nothing ends up in the repository, though I follow guides and do exactly the same without getting any errors, but ending up with an empty Github repository (except for the Readme file that I created along with the repository at the website).
I've made several Java Projects with a simple main method, and a method for just writing a dummy message, simple, but doesn't exist in repository.
Then I right click the project, select Team -> Share Project and select:
Repository: NewGit - /home/jannik/NewGit.git, working tree: /home/jannik/NewGit and Path within repository: dummy and click my dummy project and press finish.
Now I right click my project again and choose Remote -> Push and choose the default option called Configured remote repository which says origin: https://github.com/< my-github-account>/eclipseTest.git which tells me that it links to my repository named eclipseTest (which I made on website).
I then press Next and press *Add all Branches spec and clicks next, and then Finish. I then get a dialog saying that Master and NewGit branches are up-to-date, though my dummy project is missing.
If I try the Commit option in Eclipse, I get an error saying that there're no staged files
What am I doing wrong?

Before being able to push anywhere, you need to add and commit first.
See "EGit/User Guide/Commit" for adding and committing.
Its Track Changes sections shows how to add files to the index.
Click Team > Add to Index on the project node. (This menu item is named Add on older versions of Egit.)
Then:
Click Team > Commit in the project context menu.
Finally, you can push.

go to >Theam > commit >
you will get the changed list of files and in those you can move changed files to staged changes block and then commit.
See this image you can find the solution:

Related

How can I start a project on GitLab repo with Eclipse?

Good morning.
I just create a GitLab private repo to work in a project with some people. When I add GitLab repo to Eclipse, it says there aren't projects (and it's true). I would know how to create a project and sync with online repo so other members can see my project and codes.
I tried to start a project in git\repoName\ folder, then right-click and choose Team->Commit, but changes wouldn't save (in gitLab repo's website, it says "Repo is empty").
I tried to follow some online guides, but without success.
Sorry for bad english!
Eclipse 4.2 and newer, comes default with (E)Git installed. There is a good Eclipse git tutorial from Vogella.
Create a GitLab git repository
Log into GitLab
Create a project / git repository
Copy the https url from the project, used for cloning
Adding an GitLab git repository in Eclipse
Open the Git perspective in Eclipse
Use Clone existing Git repo, as shown in Using git repository view
Now all the git functionality from Eclipse can be used.
I assume you have a cloned repository available in Eclipse (eGit) that is empty. If not, follow the steps in the answer from Verhagen.
By now, you have a cloned repository that is marked with "[NO HEAD]", indicating that no commit has been made.
Start creating a new project by using your project type of choice; I'll use Java project for simplicity: File menu > New > Java project
in the New Java Project wizard un-tick the "Use default Workspace location" checkbox; instead, choose the directory where you cloned your empty GitLab project, and append the name of the project (this is to make Eclipse create a directory inside the repository, just in case you later want to create more projects in the same repo).
Fill in the wizard as you usually do. When you are done with the different steps, you'll have a new project, that is also marked with "[NO HEAD]"
Create some source files you want to share (e.g. HelloWorld.java)
Synchronize workspace (right click on the new project > Team > Synchronize workspace) you will see that now there are files to commit. Pay attention to those files, since some of them ( .gitignore, and maybe .classpath, .project,.settings directory... depending on how you share your projects) you'll want to add to the .gitignore.
right click on the files you want to commit, fill in the commit message and click "Commit and Push". Click Next
Since it is a new repository, you'll have to configure the Push action. I selected HEAD as source and HEAD as destination. You might want to do the same, at least for this first commit+push; later on, you might choose to add some specs for branches, etc.
The Push Confirmation will show you that the new branch master:master will be created.
Both project and repository lost the "[NO HEAD]" marking
You can check gitlab site to confirm your files are there.

How do I add an Eclipse java project with EGit to Github?

I have created a repository on Github and have the project in my Eclipse. I also have the Egit plugin and Github plugin. I've looked all over the internet for help on this, but I at last must turn to the Stack Overflow community.
How do I add my java project from eclipse into my repo on Github?
There are a few tutorials out here on how to import projects from git into eclipse.
Though, you can follow these steps:-
Choose the "Git" Perspective, from Window->Perspective->Open Perspective->Other, and then search for Git and select it. This opens the Git repositories view.
From the "Git Repositories" view , choose the option which says "Clone a git repository and add the clone to this view."
Follow the wizard, enter all the details.
Choose the branches you want to import.
Choose the local directory, select clone the sub-modules.
You can choose to import all existing projects by checking the box against "Import all existing eclipse projects", now or you can selectively import projects later. Hit finish.
The git repositories view will now show your repository.
Now you will need to import projects from this repository, only if you havent selected the "Import all existing eclipse projects" box before.
Right click on your repository from the Git Repositories view. Select "Import Projects" option.
Check the radio option, "Import existing Eclipse projects", select the project from your working directory. Click next and then hit Finish.
The Project Explorer should now be showing your project listed there and the name of the branch in square brackets.
Make changes, add files, edit files, once you are ready to make your first commit. Right click on your project under Project Explorer, select Team->Pull.
If this is your first commit, it will say Nothing to update - everything up to date. Hit Ok. Otherwise, it will download the changes, if there are merge conflicts , it will show you those. There are other tutorials which will guide you through dealing with merge conflicts.
Right Click again on your project, select Team->Commit.
This opens a Commit Changes window, leave a meaningful commit message.
Select Commit and push.It should ask you for your username and password, you can check the box, which says store these.
Should show Pushed to origin with Message Details. Hit ok, and you are done with your first commit.
Select a project. Right click, Team->Share. Select the Git provider. Follow the wizard.

How to properly use EGit with Eclipse

The only way I seem to be able to get use git in eclipse is to create a non-git project then turn that into a repository. This ends up moving the project out of the eclipse workspace on the file system. I then have to delete the project(it's still in the git repository), then import a git repository after creating a branch and clone it to get it back into the eclipse workspace.
Is there a simpler way?
I simply want to create project that is really a clone from a local repository. Essentially I have two copies on my HD but I can commit the eclipse project to the git repository. Unfortunately there has to be a better way?
To answer this question involves three steps.
Create a external (remote) repository
Share the project in a way that it remains in the workspace
Connect the project repository to the remote repository
Create a Remote Repository on Your Local Machine
Switch to the Git perspective. Click on Create a new Git Repository.
When a dialog appears select a directory where you would like your remote
repository to be. This is were your project will be pushed to. You will also
want to select the Create as a bare repository option.
That's it for this step. You should now have this repository in your EGit
repositories list.
Sharing Project within the Workspace
There are two ways to share a project so that it remains in your workspace.
1. Make the project directory a repository
2. Make the whole workspace directory a repository
The Project as a Repository
The first option option is not recommended by the Eclipse team. This issue is
described in more detail at Why is not recommended to have an Eclipse project folder as a Git repository?.
The basics of the issue are twofold:
You can't have more than one project per repository
If some thing happens to your workspace you'll lose your repository too
Issue 1 isn't solved here. Issue 2 can be solved by connecting to a remote
repository as show later.
To share the project as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click Use or create repository in parent folder of project
Select the project from the list
Click on the Create Repository button
Click the Finish button
Next you'll want to connect your newly created repository to the remote repository.
That's covered below.
The Workspace as Repository
The second options allows multiple projects to be added to your repository.
In fact any new project you create will automatically added to the repository.
Automatically adding projects can cause some issues.
One issue is that, if there are changes in multiple projects, staging
those changes can take a bit of wading through. Using a Tree presentation when
staging can simplify things.
Another more serious issue occurs when importing a git clone of a project into
the workspace. This importing will create nested repositories. Nested
repositories can cause problems
according to this post.
By default Eclipse doesn't import the git clone of the project into the workspace.
To share the workspace as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click on the Create button
Select your workspace as your Repository directory
Click the Finish button
Once your repository is created you may want to do a little house keeping. I suggest
adding the RemoteSystemsTempFiles project to the .gitignore file. Note: the
.metadata file is added automatically by Eclipse.
You can ignore the RemoteSystemsTempFiles by:
Switching to the EGit perspecitive
Selecting the workspace repository from the list of repositories
Select the Git Staging tab
Click on the View Menu button on the right side the the tabs toolbar
Select Presentation -> Tree menu (folders are easier to ignore form the tree view)
Right click on the RemoteSystemsTempFiles project
Select the Ignore Folder menu
Ignore other projects in the same way
Connecting to the Remote Repository
The last stage is connecting the workspace repository to the remote repository
we created earlier. Once you've switched to the EGit perspective:
Expand your workspace respository
Right click on the Remote node in the tree
Select the Create remote... menu
Leave the remote name as origin
Select Configure fetch
Press Ok
Click on the Change... button
Click on the Local File button
Select the bare repository that you created in the first section
Click Finish
Click Save and Fetch and then Ok
You can then stage, commit and push changes in your projects and workspace.
When you first commit and push EGit will push the default branch master
to the remote and configure pulling this branch from remote repository.
Follwing the User Guide, you would need to create the .git repo within your current project path:
If the .git path is within the current project path, there is no reason EGit moves your files anywhere else.

Eclipse and EGit: How to easily review changes to ALL modified files before committing to *local* repository

I'm using Eclipse Indigo SR2 with the (built-in) EGit plugin v.1.3.0.201202151440-r and haven't been able to find any way to easily review all my changes before making a commit.
I used Eclipse with SVN for years, and this was always very easy to do. I would typically right-click on my project, select Team->Synchronize, double-click on the first changed file (in the Team Sync perspective), then hit Ctrl-. repeatedly to review all changes in one file, and then proceed to the next file, as I wrote a summary of my changes for the commit message.
But of course, git is very different from Subversion, and so my workflow must change. With EGit, "Team Sync" only appears to be useful for reviewing changes between my local files and the remote repository (i.e. before a push to the remote). I need a way to review changes since my last commit to my local repository. I generally don't even care to (re)review changes before a push to remote (and if I did, I'd prefer a simple equivalent of git log to see what commits I'm about to push).
If I right-click on my project and select Team->Commit, I am presented with a window that does almost everything I need to do (select files to stage, commit, write a commit message, amend a previous commit, etc.). What it doesn't allow me to do is quickly and easily review all my changes in a compare editor. I can't believe this capability doesn't exist! It seems I am required to double-click on each individual file, review the changes, close the compare editor, and double-click on the next file. That's ridiculous!
TL/DR - I am looking for a simple GUI equivalent (in Eclipse) to do what I am easily able to do from the command line using git vimdiff (where vimdiff is a git alias that uses vimdiff as the "difftool" to cycle through all modified files) followed by git commit (with perhaps a git add or two in between).
If no one has a good solution, I am curious about how others handle their commit workflow with EGit. I've been getting along fine committing from the command line (not that Eclipse is happy about that) but I can't believe that EGit is as near-useless as it seems to me. Perhaps my google-fu is not as strong as it once was?
Says here that you can see the diffs between the working tree and any given reference. Perhaps you should try out the latest version (Juno) of Eclipse/EGit and see if it's gotten any better?
Update: I've tried this out in the latest Eclipse, and as far as I can see it works fine. Here's how:
In the moment of writing this, Eclipse Juno 4.2 is the version you should go for. On the download page, you can pick between several packages according to your needs. The 'Eclipse IDE for Java Developers' comes bundled with EGit, but you can also install EGit into any distribution using the Eclipse Marketplace (under the Help menu).
Once you've imported your project into Eclipse, make sure the project is "shared":
Right-click project -> Team -> Share Project.. -> Git
Now do the following:
Switch to the Team Synchronizing Perspective.
Click the little synchronize button in the Synchronize View.
Choose Git
Pick a suitable branch to sync against, like refs/remotes/origin/master
Make sure to check the "Include local uncommitted changes in comparison" box
Click Finish
Now, change some files and watch them appear in the Synchronize View. Double-click the changed files to see the diff (like in the screenshot below).
Are you aware of the 'Git Staging' view. It keeps track of all the files that have changed and you can review the changes any time. (This can be a bit better than using the commit dialog)
An alternative is to commit all changes without reviewing, and then use the history view to compare two commits (Simply select the last top most commits, right click and select 'Compare with each other'). This way you do not have to keep double clicking individual files. If you need to change something you can always 'Amend' the last commit. (I usually follow this approach)
I am writing this as of Eclipse Oxygen, but it should apply to other versions as well.
Option 1 with team synchronizing view: right click the project > Compare with > Commit. You can choose your latest commit here, even if you haven't pushed it to repository.
Option 2 with diff view: If you want to see the "diff" version without committing, you can achieve this by right clicking your project > team > stashes > Stash Changes > check Include untracked files. This will save all of your changes to a stash. Then you will right click project > team > stashes > select stash you saved. You click the green arrow at the top right to re-apply all of your changes you stashed back to your code. In the same stash window, you will see a "Diff" tab at the bottom right. Clicking on the diff tab will show your changes in the red/green highlighted diff style. I wish there was a way to generate a diff view without stashing, but this is the only work-around I have found.

Eclipse Egit Not Detecting Changed Files

I have been using Egit and Eclipse together for well over a year. I recently upgraded my computer and had to reinstall everything. Previously whenever I would make a change to a file it would immediately get picked up by Egit and show with the red highlight and star next to the file name in the project explorer.
I have everything back up and running exactly as it was, however whenever I make a change the change is not picked up by Egit. I have to perform a 'git status' in order for the files to show as ready to be staged in the file explorer. Am I doing something wrong to have Egit automatically detect changed files and has anyone else had this problem?
which version of EGit are you using
do you get the egit team menu if you right-click any resource in your git tracked project ?
if not then you need to do "Team > Share > Git", then check "Use or create repository in
parent folder of project". If you are using a very recent nightly build version this
will be checked automatically.
when you modify a file tracked by (e)git a text decorator ">" should
appear in front of the modified file
as soon as you stage the modified file (Team > Add) the decorator should show the star
also the staging view should always show the git status for all modified files
You need to "Add to index" all files again probably
Track Changes Click Team > Add on the project node. (This menu item
may read Add to Index on recent versions of Egit)
(From the EGit docs:)
What I've found is that you need to make sure that your git repositories are showing up in the Eclipse Git Repositories view.
In the repositories view, you click on the [very] little Git icon with a green + (plus) sign to Add and Existing Local Git Repository.
Browse to the directory that already has a .git subdir and click Finish. You should then see you local repo show up in that list.
Then you can right click on the repo while still in the repositories view and add pull down to Import Projects.
"Import existing projects" is selected. Click Next.
Your project should be checked off. Add it to a working set if necessary. Click Next (maybe Finish).
I had a similar issue where all my changes just disappeared. Somehow, Eclipse had unselected my Git repository. Once I selected it again, they all came back.
If you have already added your files to Stage then change the branch it will ask you to commit/stash/reset
I faced the same problem. From your git repository view: Right-click -> Show in git staging
For me I have clicked Team --> Advanced --> No Assume Unchanged, fixed the issue
I faced the same problem using eclipse version 2021.12. Whenever I made changes on file, the eclipse didn't detect it.
I solve it by using Intelij IDE.
i just faced this problem by now, and i resolved by clicking in button Refresh in Git Staging: