Anyway to use an external diff editor in Eclipse with EGit? - eclipse

Is there anyway to configure Eclipse/EGit to use an external diff editor and merge tool when doing differences/merges? I've been looking for a way to use something like BeyondCompare or DiffMerge or Kaleidoscope, but so far haven't found anyway to configure it.
I realize that BC has their own plugin, but it does not work within Egit context (ie: when looking at history and comparing to working tree, etc).
I'm running Eclipse 3.7SR2 (Indigo) and eGit 2.1.0. I've tried putting stuff in my .gitconfig to use external diff tools, but Eclipse still opens the files in its own compare windows.

This is currently not supported by EGit, see bug 356832 which tracks this enhancement and also includes a workaround.

As a workaround, you could try the eclipse plugin "External Compare" (see https://sourceforge.net/projects/externalcompare). This plugin opens the contents of the internal eclipse editor in an external editor.

You can use kdiff3 for GIT merging and diffing in Eclipse:
Follow these steps to set up kdiff3 to merge git conflicts within eclipse :
Let git create a config file
can be skipped if there is already a .gitconfig file in your userdir.
Windows users:
%userprofile% (copy paste in Explorer adress bar)
a file named ".gitconfig" needs to exist there
1.1 open a cmd window, execute:
git config --global --edit
The config file was created.
Open the config file ".gitconfig"
2.1 add the following lines to register kdiff3 as the diff and merge tool for git (customize the paths to you needs):
[difftool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#
[mergetool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#trustExitCode = true
#
Note: This would be the location to register any other supprted mergetool of your liking.
Create a new "Program" "External Tools Configuration" named "git merge" to execute merges from within eclipse!
3.1 Select the following for the parameters:
Location:
C:\Program Files\Git\bin\git.exe
Working directory:
${git_work_tree}
Arguments:
mergetool --tool=kdiff3
To execute a merge, use the standard eclipse merge and as soon as the workspace shows the conflicted state (red markers on projects visible) you mark a project you wish to merge and start the "external tools configuration" we created in the steps listed above.
The merge will start and the kdiff3 window will pop up.
from now just go along your business and only save the files when you are happy with the merge result, as kdiff will deliver a positive merge feedback if you have saved the file.

Related

EGit in eclipse not detecting changes in a JAR file

I am using git to check in codes from eclipse and my project uses "SparkChat.jar" for it's chat feature. I modified the code for sparkchat a little and generated an updated SparkChat.jar, but when i tried checking in, git doesn't recognize that SparkChat.jar has been modified.
Is there anyway i can 'tell' git that SparkChat.jar is dirty and needs to be checked in?
Edit: To clarify, i am using EGit implementation in Java Eclipse, not command line.
Hit the Refresh button in the toolbar of the Git Staging or Git Repositories view to synchronize Eclipse with the changed files of the file system:
If it is a file in a project, a Refresh (F5) in the Project Explorer or Package Explorer should also work.
It seems, there is a bug (or intended "feature"?!?). You have to close and reopen Eclipse! :-( That's the only way with my Eclipse to see file system changes in the 'Git Repositories' Windows! :-((

Check-in .project file to GitHub repository

I'm using LiClipse which is based on Eclipse. With EGit, I pushed most of the files and directories into a GitHub repository.
However, there is one file that I can not find a way to check in to the repository: .project, the XML file.
How do I check in this file? Even manually?
Maybe you can (from a command-line git session) add a .project, but you can't from Eclispe, because Eclipse filters by default the "resource files", ie the '.*' files.
If that is the case, see "How can I get Eclipse to show .* files?".
Then, if that file isn't ignored by git, you can add it.
Or you can force the add (at least in command line: git add --force)

Line break changed in some files using EGit

I'm using Eclipse Juno with EGit 2.0 and I'm having the following problem:
I've just cloned a rather big project using EGit, I haven't edited any file and I have some files to commit. If I check the repository status with git status I see those files as unstaged modifications.
If I do Compare With -> HEAD Revision in eclipse for any of those files I don't see any difference. However, when I do git diff I see things like this:
diff --git a/PortalPlatform/WebContent/WEB-INF/fragment/someFile.jsp b/PortalPlatform/WebContent/WEB-INF/fragment/someFile.jsp
index f883dba..811ad83 100644
--- a/PortalPlatform/WebContent/WEB-INF/fragment/someFile.jsp
+++ b/PortalPlatform/WebContent/WEB-INF/fragment/someFile.jsp
## -34,7 +34,7 ##
</c:forEach>
</select>
</c:if>
- <div><fmt:message key="label.link" /></div>
+ <div><fmt:message key="label.link" /></div>^M
</fieldset>
<div class="widgetBut">
<a class="btn primary submit" href="#"><span><fmt:message key="button.reprint" /></span></a>
It hasn't affected a particular file type, I get the problem with .java, .jsp, .css, .properties and .xml files.
Why did I get those changes in the line breaks only in some files? How do I fix it?
Thanks in advance!
Since EGit 2.0, according to bug 301775, EGit supports core.autocrlf.
It used to set autocrlf to false when creating a repo, but bug 382067 and fix 6316 took care of that, which means it relies on the local or global settings you have in your local Git installation (like msysgit).
And as I have said before, this should always be set to false.
If you need fine-grained control on the EOL of certain files, use core.eol attribute.
Kind of old question but still someone can have a problem (as i had).
EGit Documentation > EGit User Guide > Getting started that can be found here states:
Pointing out the System wide configuration
If you use Git for Windows as a companion to EGit, make sure EGit knows where Git is installed so it can find the "system wide settings", e.g. how core.autocrlf is set. Go to the settings and look under Team>Git>Configuration and then the System Settings tab.
If you selected one of the options to use Git from the Command Line Prompt when you installed Git for Windows, then the location of the system wide settings is filled in with a path and everything is fine. If not, use the Browse button to locate where Git is installed, e.g. C:\Program Files(x86)\Git.
This advice also applies to users of other Git packagings, e.g. Git under Cygwin or TortoiseGit.
Non-Windows users should in theory check this setting, but the system wide settings are usually not used on non-Windows platforms.
So as we can see, EGit looks for git config files to khow how 'autocrlf' is exactly configured. But under Windows it seems it does not find all of them.
This command will show us what config git uses:
git config --list --show-origin
And what git's configs are taken into account in Eclipse we can see in Windows > Preference > Team > Git > Configuration. Here is a problem: Eclipse doesn't see config file located in C:\ProgramData\Git folder where 'autocrlf' option defined.
I ended up by duplicating 'autocrlf' value (true - in my case)
[core]
autocrlf = true
in user '.gitconfig' file located in home directory and everythings worked fine.
See also git on Windows - location of configuration files.

Git shows files changed, but EGit does not

Git noob here. Having a hard time figuring out why git shows some files changed, while Eclipse EGit does not.
When I use EGit within Eclipse and view a project, it shows no files changed. There is no little caret next to each file. When I use Git for Windows, or go to the command line and type "git status", it shows that all the files have been modified. When I type "git diff" it shows two different versions of a file, first red, then green, and there appears to be some whitespace differences, but I can't be sure, and I can't figure out how the whitespace changed in every file in the project. (Something here doesn't add up.) "git diff -w" returns nothing. "git config --global apply.whitespace nowarn" does nothing.
I might be having a basic conceptual problem with git.
In any case, why do EGit and the git command line show different results?
EGit understands the notion of Derived resources (e.g. used for generated .class files in JDT). In other words, files in derived resources are not added to version control by default in EGit. However, the command line git client does not know these markers, but relies on .gitignore files to avoid checking in generated files.
To check whether your problematic files are derived, open the file properties dialog (right click on the file in the explorer, and select Properties...), and on the Resources page check for the Derived checkbox (it should be around the middle of the dialog).
It turns out that git is playing games with newlines. It's inexplicable. Bottom line: EGit and the git command line cannot both be used on a Windows box. To get consistency, you have to use one or the other.

NetBeans and Mercurial - moving/deleting files and folders

I'm wondering if when using NetBeans and its Mercurial plugin I can only move/delete files/folders through the project navigator or I can change the project structure through the file explorer (Finder) and edit files using other editors then push the changes through NetBeans without issues.
Thanks.
You can edit files with other editors. If you add, delete, or rename files from outside Netbeans I think you have to run hg addremove, I don't think it can be done inside Netbeans. See hg help addremove for more information on what it does. To track renames people often recommend to use the similarity option with 90 as argument.
See also Netbeans Mercurial plugin doesn't have addremove option in GUI menus