Git plugin - "Cannot pull with rebase because of the following uncommitted files"

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
chrispitude
Posts: 250
Joined: Thu May 02, 2019 2:32 pm

Git plugin - "Cannot pull with rebase because of the following uncommitted files"

Post by chrispitude » Sun Aug 16, 2020 3:27 pm

Hi all,

We are heavily using the Git plugin in Oxygen. We've switched from merge pulls to rebase pulls to simplify the commit graph, and it's been great! The only wrinkle is that sometimes users get an error:
Cannot pull with rebase because of the following uncommitted files:
But it didn't always happen when uncommitted files were present, so I did some experiments to figure it out.

1. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I pull (B) first:
git-rebase-pull-before-commit.gif
git-rebase-pull-before-commit.gif (149.85 KiB) Viewed 164 times
2. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I commit (A) first:
git-rebase-pull-after-commit.gif
git-rebase-pull-after-commit.gif (161.3 KiB) Viewed 164 times
3. If I have (A) an uncommitted file and (B) there's an unpulled commit and (C) there's an unpushed commit, the rebase pull succeeds if I push (A) first:
git-rebase-pull-after-commit-existing-commit.gif
git-rebase-pull-after-commit-existing-commit.gif (191.95 KiB) Viewed 164 times
So it's the combination of (A), (B), and (C) that cause the problem.

The error can be avoided if you can remind writers to always pull before committing. However, not everyone will remember to do that.

I'm guessing this occurs because the presence of the local unpushed commit causes Git not to be able to do a simple fast-forward of the head commit. Research suggests that the normal way to handle this is to do a stash-pull-unstash. There's even an "autostash" feature to make this easier. However, we don't have access to those features in the Git plugin.

chrispitude
Posts: 250
Joined: Thu May 02, 2019 2:32 pm

Re: Git plugin - "Cannot pull with rebase because of the following uncommitted files"

Post by chrispitude » Mon Aug 17, 2020 4:20 pm

The following Git plugin enhancement should avoid this scenario:

https://github.com/oxygenxml/oxygen-git ... /issues/98

sorin_carbunaru
Posts: 328
Joined: Mon May 09, 2016 9:37 am

Re: Git plugin - "Cannot pull with rebase because of the following uncommitted files"

Post by sorin_carbunaru » Mon Aug 17, 2020 5:48 pm

Hello Chris,

According to the JavaDoc from the JGit developers, this scenario happens when "the repository contains uncommitted changes and the rebase is not fast-forward".

Based on some old experiments of mine, an example of this happening is when we have local changes in files X and Y, and there's also an incoming change from remote on X. At this moment, we choose to commit X and try to pull with rebase, still having Y locally modified.

The issue you mentioned has already been tackled. We added an option (a check box) to allow notifying the user when new commits pushed to the remote repository are detected.

You could try this feature by cloning the Git repository from https://github.com/oxygenxml/oxygen-git-plugin on your PC and build the project locally using Maven. Unzip the resulted JAR inside {oXygenInstallDir}/plugins. Make sure you don't create any intermediate folders. After unzipping the archive, the file system should look like this: {oXygenInstallDir}/plugins/git.support-x.y.z, and inside this folder, there should be a plugin.xml file. After doing this, start Oxygen and look for the Plugin > Git Client preferences page and activate the option.

Regards,
Sorin Carbunaru
Oxygen XML Editor

chrispitude
Posts: 250
Joined: Thu May 02, 2019 2:32 pm

Re: Git plugin - "Cannot pull with rebase because of the following uncommitted files"

Post by chrispitude » Mon Aug 17, 2020 10:01 pm

Hi Sorin,

The troublesome thing about this for us is that they don't have to be the same file. The remote commit can be any file, even a file that isn't being worked on locally; it's not just conflict cases. I am surprised the rebase behavior is this limiting, to be honest.

I'll try building the plugin and report back, thank you! I appreciate the extra detail you gave on how to do it, as all of it is new to me and I would no doubt struggle without your guidance.

Post Reply