How can you unstash changes using EGit? - eclipse

When I switch branch with non-committed changes I'm given a prompt to stash my changes:
When I switch back to the branch with the stashed changes I can't see any of the non-committed changes.
Using EGit how can I retrieve the stashed changes?

EGit 3.5 and later
In EGit 3.5 and later, there is a menu called Stashes in the Team context menu. It provides an action to stash changes and also lists any existing stashes. The same menu is also available as a toolbar icon and in the Git Repositories view:
Selecting an existing stash from the menu opens it in a viewer. The changes can be inspected and there are actions for applying the stash or deleting it:
EGit 3.4 and ealier
Open the Git Repositories view (Ctrl+3 and typing, Cmd+3 on Mac OS X)
Expand the node of the corresponding repository
Expand the Stashed Commits node
Open the context menu of the stash and select Apply Stashed Changes

In Eclipse (Luna) + eGIT, you can restore stash as

Related

Eclipse: Git how to push after a local commit

I sometimes realize a local commit with Eclipse and then decide to push my project but Eclipse offers me only two solutions "Commit and Push" or "Commit".
The problem is I cannot make a "commit and push" if I haven't changed anything after my "Commit".
Fair enough, I only have to change a line on my code and can push it but it seems to me like an awkward solution. Is there a better way to do so?
You can always just open Eclipse's built-in terminal (or any other terminal app) and execute: git push.
On a side note: getting used to using git on the command line enables you to easily switch between different IDEs and editors without having to re-learn the respective quirks of the git integration of the IDE de jour every time you switch.
In the Package Explorer, Project Explorer, etc. right-click the project folder and choose Team > Push to Upstream.
Alternatively, you can use Quick Access (Ctrl+3) and enter push to upstream (assuming a file of a Git repository is selected or opened).
For a Git main menu and Git icons in the main toolbar, in Window > Perspective > Customize Perspective..., in the tab Action Set Availability check the checkbox Git.

Eclipse EGit | Branch Diff

Currently using Eclipse Mars.1 and installed EGit from Eclipse MarketPlace.
Does Eclipse EGit has a similar feature of SourceTree wherein you could pick N or all commits inside a branch and compare it (git diff) to which branch is was checked-out from?
I was trying to follow low-level git branching standards relying only on Eclipse EGit tools (without terminal, SourceTree, Pull Request functionality, et.al.). But I'm only limited to seeing commit-diffs and not a branch-commit-diff view.
I think you can compare anything to anything in egit.
e.g.:
You can click on any two commits in the History view and, from context menu, choose Compare With Each Other
You can select two branches in the Git Repositories view and, from context menu, choose Synchonize with each other
You can right click on any branch in the Git Repositories view and choose Synchonize with workspace
And the list goes on ad infinitum (practically).

How to show current git branch in Eclipse toolbar

Is there a plugin or some setting in EGit to show the current git branch in the toolbar of eclipse so that it's visible on which branch you're working?
Like Sasikanth says there is no toolbar in EGit that shows the current branch.
Since there usually are multiple repositories within your IDE, a toolbar that shows the current branch of a single repository would probably often choose the wrong repository to display.
But if you have an idea how such a toolbar could work you may want to open an enhancement request.
In the meanwhile you can either use the Repositories View to see the current branch of each repsoitory or look at the Pakckage Explorer or Project Explorer. The projects are decorated with the repository they belong to and the current branch that is checked out.
Here the project belongs to the gitexample repository on branch master.

Changing the git branch on eclipse

This is the first time I do this.
I imported a git project in eclipse.
Then I used the shell to create another branch and checkout to the new branch.
Is refreshing the imported project in Eclipse enough to tell Eclipse that we are working on the new created branch?
thanks
Right-click your project and select Team → Branch to create new branches or to switch between existing branches. You can also switch branches in the History view.
Actually, I don't think you even need to refresh the project. That is, assuming you have 'eGit' installed and your projects are already configure as git projects (they should be, because in most cases, egit does that automatically).
Whenever you run git commands on the shell (outside eclipse) egit will automatically refresh projects for you and update their status when you switch back to Eclipse.
If you are not using egit then yes, you have to refresh the projects manually, but that is all you'd have to do since running the 'git checkout my-branch' command in the shell already changed the files on disk to be those from 'my-branch'.
Actually when you are working with eclipse, eGit is a very cool tool integrated inside eclipse, which lets you do all git stuff, like
git checkout to a new branch
git create new branch
git stash
even view your unstaged changes(select files and avoid complexities caused by git add .)
and finally commit.
Read here to know more. Eclipse Egit user guide
So you get to do all version repository stuff at one place as you code.
So to answer your question, yes as you checkout a new branch even in a shell/command prompt your changes will be reflected in eclipse.

EGit automatically add new files

When executing a commit of a set of files within the EGit eclipse plugin, I always have to add new files manually in the commit dialog
Is there a way to configure the plugin in a way, that adding new files automatically is the default setting?
Such an option exists now, it can be enabled in the preferences in Team → Git → Commit Dialog by checking Include selected untracked files:
Note that only untracked files that are contained in the selected files/folders/projects are included – so it depends on where you opened the context menu from.
Right now, there doesn't seem to be any option to have all new files added automatically.
(and this wouldn't be possible as well with Git)
Even on the commit stage, Git proposes only git commit -a -m "..." in order to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.
In other word, this would be a new feature in EGit which wouldn't have any direct correspondence in Git.