Git plugin - "Cannot pull with rebase because of the following uncommitted files"
Posted: 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:
1. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I pull (B) first:
2. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I commit (A) first:
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:
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.
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:
But it didn't always happen when uncommitted files were present, so I did some experiments to figure it out.Cannot pull with rebase because of the following uncommitted files:
1. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I pull (B) first:
2. If I have (A) an uncommitted file and (B) there's an unpulled commit, the rebase pull succeeds if I commit (A) first:
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:
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.