Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1861a7b

Browse files
committed
rn-126: add pull.autostash article
1 parent e4b4e71 commit 1861a7b

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

rev_news/drafts/edition-126.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,84 @@ This edition covers what happened during the months of July 2025 and August 2025
2525
### Reviews
2626
-->
2727

28-
<!---
28+
2929
### Support
30-
-->
30+
31+
* [[BUG] git pull ignores pull.autostash=true configuration when used with --git-dir and --work-tree flags on a bare repository](https://lore.kernel.org/git/010001980c1ee007-2797fc86-fdf3-46e9-bec9-f8da2c9ebb8d-000000@email.amazonses.com/)
32+
33+
Bryan Lee posted a bug report about the `pull.autostash`
34+
configuration variable being ignored in a repository used to manage
35+
his dotfiles.
36+
37+
He expected his unstaged changes to be automatically stashed before
38+
a pull when that configuration variable is set to `true`. Instead,
39+
the command failed with an error message telling him to "Please
40+
commit or stash them". So he thought Git ignored the autostash
41+
configuration completely due to the setup, which consisted of a bare
42+
repository and a separate work tree accessed through the following
43+
alias:
44+
45+
`$ alias dot='git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'`
46+
47+
Lidong Yan replied to Bryan admitting that he wasn't sure why the
48+
autostash feature would be ignored when using the `--git-dir` and
49+
`--work-tree` flags. He suggested setting `rebase.autostash` instead
50+
of `pull.autostash` to `true` though.
51+
52+
Bryan Lee thanked Lidong saying that `pull.autostash` is not a Git
53+
configuration option and that `rebase.autostash` does work for
54+
rebase operations. But he raised the issue that Git silently accepts
55+
invalid configuration keys without any warning, which can cause
56+
users to waste a lot of time debugging.
57+
58+
Lidong replied with a suggestion to add a `git config verify`
59+
subcommand. But Junio Hamano, the Git maintainer, chimed in
60+
expressing doubts about such a command, as Git cannot distinguish
61+
between a typo of a known variable and a legitimate custom variable
62+
that a user or a third-party tool might be using. Lidong elaborated
63+
that such a command could work by having Git maintain an internal
64+
registry of all valid keys, which could also be extended by users
65+
and tools for their own custom configurations.
66+
67+
Johannes Sixt suggested that instead of building a complex
68+
verification system, it would be easier to fix the origin of the
69+
misconception that `pull.autostash` was the correct configuration.
70+
71+
Junio replied to Johannes that having `git pull` pay attention to
72+
`rebase.autostash` was at least a documentation failure, if not a
73+
bug. He argued that users have different expectations for a
74+
relatively safe local rebase compared to a pull from a remote, which
75+
could be riskier. Also it didn't make sense for `git pull` to
76+
respect `rebase.autostash` but not `merge.autostash`.
77+
78+
Ben Knoble then chimed in with a counter-argument to Junio. He
79+
reasoned that since a `git pull` that rebases is conceptually a
80+
fetch followed by a rebase, it would be "far more inconsistent" if
81+
it didn't honor the rebase configuration. Breaking that expectation
82+
would be unnatural for users taught to think of pull in that
83+
way. Following this logic, he also supported the idea that a merging
84+
pull should respect `merge.autostash`.
85+
86+
Then Junio wondered if introducing a new, dedicated `pull.autostash`
87+
variable would be a good idea. But soon Lidong came up with
88+
[a patch](https://lore.kernel.org/git/[email protected]/)
89+
to actually add this configuration variable.
90+
91+
Eric Sunshine reviewed the patch and left a number of suggestions to
92+
improve it in many ways. After some discussions with Lidong and
93+
Junio, Lidong posted
94+
[a version 2 of the patch](https://lore.kernel.org/git/[email protected]/).
95+
96+
This new version implemented a number of improvements based on the
97+
discussion. Some tests were added. The logic was updated to fall
98+
back to either `rebase.autostash` or `merge.autostash` depending on
99+
whether the pull performed a rebase or a merge. The order of
100+
precedence was also clarified: `pull.autostash` now overrode the
101+
more general `rebase.autostash` and `merge.autostash`
102+
settings. Finally, the documentation was updated with more precise
103+
explanations.
104+
105+
This feature was released recently as part of Git v2.51.0.
31106

32107
## Developer Spotlight: Seyi Kuforiji
33108

0 commit comments

Comments
 (0)