1

I'm working in Eclipse Photon and my team uses git. I choose not to do anything with the Eclipse git plug in, I just do everything I need with git using a third party application and command line. Egit is installed though. Not sure if any of that factors into my issue.

But I've noticed a couple times now if I start working on a feature branch, add a couple new files in Eclipse, commit my work, then need to switch to another branch for some reason, and then switch back to my feature branch, those new files I added before will not show up in my project explorer in Eclipse, even after refreshing. To be clear, this happens when I switch to one branch that doesn't have my new files, and then back to my feature branch that has the new files. This has been driving me crazy. It's not an issue of git doing anything wrong, git is working as expected. When I switch away from my branch, the files are gone in windows explorer, and when I switch back, they are there again in windows explorer. The only solution I've found, which works inconsistently, is to close and reopen Eclipse. Which is a huge waste of time for how slow Eclipse is. Anyone have any ideas about what might cause this behavior?

I've been using this setup for a while and only just started noticing it. Refresh does nothing for me. I've tried importing my new file, but this leads to an error stating that my destination already contains the file in its hierarchy. Well, that makes sense, because it does. And yet, Eclipse still won't show me the file in the explorer. I can open the file into Eclipse from windows explorer, and even then, Eclipse won't show me the file in the explorer. This wouldn't be too much of a bother, except it's invisible in my references and searches too, which is annoying because I'm working on and referencing things in the new files.

Thanks for any help!

JLuce
  • 43
  • 6
  • What's the name of this file, and where is it in the hierarchy? – nitind Dec 19 '19 at 01:55
  • It's about 5 levels deep into the hierarchy in a folder with many other files with names formatted the same way. The name is just letters with a couple underscores and dashes (example_of-my_file.src). It's neither particularly long or short either. All my file names have underscores and/or dashes. Is there a chance filename or file/folder name combination could be an issue? – JLuce Dec 19 '19 at 14:54

1 Answers1

1

One explanation, especially on Windows, is Eclipse having trouble refresing its workspace because of Windows handles preventing it to do so. Hence the close/reopen workaround.

Check if you can use git worktree and define a separate working tree dedicated to your feature branch.
You might then switch, from Eclipse, between working tree, through two different Eclipse workspace: that might be faster than closing/reopening.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the recommendation, I was unfamiliar with git worktree but that sounds like maybe I could get around my problem. If I'm understanding correctly, I'd essentially be able to work on two branches at once, right? Switching between workspaces would be less annoying than closing and reopening, but let's say I'm working in my feature branch, and then need to do a small task in a different branch, could I simply open another instance of Eclipse to that workspace with that worktree? – JLuce Dec 19 '19 at 15:01
  • To synchronize Eclipse with Git you have to hit _Refresh_ in the _Git Staging_ or _Git Repositories_ view, not _Refresh_ in the _Project Explorer_ (which is to synchronize with the file system). The fastest way for branch switching is to use the latest Eclipse respectively EGit version (2019-12 respectively 5.6) without using the Git command line. To use the command line is a bad advice here, because that requires synchronization for no reason each time. – howlger Dec 19 '19 at 19:48
  • I won't say that EGit is bad, but I really prefer using command line and a third party UI for most things. I do like the Show Local History Eclipse option, so I do keep EGit around though. Thank you for the input just the same. This solution just isn't my preferred solution. In the past, Eclipse has been very good about refreshing correctly after I make workspace changes in git outside Eclipse, so I'm not sure what's changed now. – JLuce Dec 20 '19 at 15:46
  • @JLuce Eclipse Photon quite old. EGit and JGit are developed very actively, for example by Google, who use JGit on the server side (in gitlib and Gerrit). For example, the current JGit version has already [reftable](https://eclipse.googlesource.com/jgit/jgit/+/master/Documentation/technical/reftable.md) support, which is not yet supported by git-core (command line Git). Also, [refreshing has been tuned](https://wiki.eclipse.org/EGit/New_and_Noteworthy/5.6#Performance_Improvements). [Watch my videos](https://www.youtube.com/channel/UC_6g5CvFpKUqg_dbmxsSgow/videos) what has changed since Photon. – howlger Dec 22 '19 at 09:15