-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not enable auto fetch by default #343
Comments
Those settings' default values haven't changed since they were introduced over a year ago.
We should not auto-pull changes if you have uncommitted changes locally. Instead we should be showing you that you have incoming changes in the status bar item. If you are experiencing that the file contents change from under you, can you please share a screen recording or some repro steps? Thanks! |
I understand the value of having an auto fetch enabled for some workflows (as you point out), but it would be best to not have contradicting defaults on the various extensions (Git extension vs. Github repositories and Azure repo extensions) and follow the principle of least surprise. On a related note, I find the action done by the sync button (i.e. pull) to be dangerous too, and people I know just avoid it, because it will do a pull merging upstream changes with local changes without asking, and it is usually not what one wants. One wants to have control over the git commit history and not just blindly merge. But that is outside the Github repositories and Azure repo extensions. |
Apologies, I don't understand the issue that you run into here
Can you provide a concrete example of a workflow that is broken by the auto fetch behavior? Do you mean that you have local uncommitted changes in a virtual GitHub/Azure Repos repository, someone else force pushes to the branch you're on, and your local view of those files is updated while you still have uncommitted changes? |
I've found this blog post which explains the use of git push --force-with-lease much better than what I can do: https://itnext.io/git-force-vs-force-with-lease-9d0e753e8c41 The thing is that force-with-lease will compare the commit id of the remote branch HEAD that it knows of locally (e.g., remote/origin/mybranch), which is only updated on a fetch, with the current one at the remote git repo. If they do not match then the push errors out. This allows to detect if someone else pushed to the branch upstream since the last fetch, and avoid losing those new commits otherwise. Workflow can be like this:
If there is something doing periodic fetches in the background it would break this workflow, because the expected remote HEAD would be updated without me knowing, losing the value of the --force-with-lease option. That is why I think that defaulting auto fetch to enabled is a dangerous thing. Let me know if this explanation was clear enough. |
Recently the Github and Azure repos extensions started to automatically doing a fetch in the background.
This is controlled via the "Github Repositories › Auto Fetch: Enabled" and "Azure Repos › Auto Fetch: Enabled" settings, which default to enabled.
This is problematic for people that use
git push --force-with-lease
because the local view of the remote changes without knowledge of the user and it is all too easy to trample over someone else's commits in a PR without noticing it.I do not know if this is because the extension gained that capability recently, or the setting was changed, but I think it should be changed to default to disabled.
Also, the Git extension has an equivalent setting, called "Git: Autofetch", which defaults to false. So it is really surprising to have different defaults.
In my opinion, I think that the defaults for Github Repositories and Azure Repos should inherit from the setting of "Git: Autofetch", with the possibility to override it for these extensions, and same for the associated periods.
The text was updated successfully, but these errors were encountered: