intellij-community
intellij-community copied to clipboard
Add new Git update methods for convenient fetching
It is often desirable to fetch upstream commits first and then decide what is best: merge, rebase, or maybe even postpone updating and discuss your changes with other developers first.
However, at the moment IDEA doesn’t provide an easy way to just fetch. There is the Fetch action, but it’s not bound to a keystroke by default, which is inconvenient. It’s possible to bind it manually, but it’s not without drawbacks: it won’t work on someone else’s PC, you need a spare keystroke for that, and it won’t be consistent with other Git GUIs, like Git Extensions, for example, which just provides a list of possible update actions in a single drop-down menu, including Merge, Rebase, Fetch, Fetch All and Fetch and Prune.
So what I did here is add a couple of new “fake” Git update methods: Fetch Default and Fetch All. Seems to be working nicely to me, except for one usability quirk: after fetching is done, an “All files are up-to-date” notification pops up, which can be a bit confusing, as something like “Fetched N new commits from ...” would be more useful. However, this isn’t possible to do without reworking the VCS Update API considerably, and I’m not sure if such a minor annoyance is enough to justify that.
Hello, thank you for your contribution! Could you please elaborate on why you want to use the Update project dialog here? It seems assigning a default shortcut to the Fetch action is an easier and better way to achieve what you want?
Several reasons, although all of them are debatable, and I can’t say with confidence that this is the best way to do it.
- As I’ve mentioned, there is no default binding for Fetch. Manual binding is possible, but not without the above-mentioned drawbacks, such as it won’t work on someone else’s PC, needs to be set up on every computer, may conflict with new standard bindings in future versions of IDEA.
- I can’t come up with a convenient keystroke for Fetch. A lot of them are already used for something else. A lame excuse, of course, but something that’s easy to remember would be desirable.
- If I want to never automatically merge or rebase, which is quite often the case in my experience, I can just set up the default update method to one of the fetch methods and never worry about accidentally pressing Ctrl+T and screwing up my current branch. This is the way Git Extensions work, by the way, which I find very convenient in this regard.
- Fetching and updating are closely related tasks, so it makes some sense to put them in one place and have a single shortcut.
While these reasons are admittedly weak, I also don’t see any reasons not to put these methods there. It doesn’t add any new actions, doesn’t occupy new keystrokes, doesn’t lead to any confusing behavior by default. Whenever a developer that is used to dealing with Subversion, for example, migrates to Git, they just press the same keystroke and see all update options available to them.