1

In this comment, @torek (reputation currently 172,509) said:

I actually recommend avoiding git pull entirely, for the same reason you recommend avoiding --autostash

The reason given for avoiding git rebase --autostash was:

It seems convenient when it works but is problematic when it doesn't

In which ways can git pull be problematic when it doesn't work?

My robust automated solution to avoiding git pull --autostash is non-trivial.

Is there a robust automated solution to avoiding git pull?

Tom Hale
  • 40,825
  • 36
  • 187
  • 242
  • 1
    What does `pull` have to do with `rebase --autostash`? Also, remember a pull is just a fetch then a merge. – evolutionxbox Oct 18 '18 at 08:41
  • @evolutionxbox presumably it's a series of commands (stash push, rebase, stash pop / fetch merge) which can lose information (eg exit status). See the links for more context. – Tom Hale Oct 18 '18 at 09:17
  • 2
    "Robust" tends to be hard. Since pull = fetch + 2nd-git-command, run `git fetch` (which is pretty safe at all times assuming standard configurations), then build the robust part around whichever second command you want. – torek Oct 18 '18 at 15:28
  • 1
    Possibly relevant: https://adamcod.es/2014/12/10/git-pull-correct-workflow.html – chevybow Oct 18 '18 at 15:42
  • @chevybow Excellent, that was the answer I was after. Thanks! – Tom Hale Oct 19 '18 at 12:35
  • Don’t avoid pull: create lots of branches, and communicate when merging. – D. Ben Knoble Dec 29 '18 at 03:51
  • [This old guide](https://longair.net/blog/2009/04/16/git-fetch-and-merge/) explains the point rather well IMO: – kostix Dec 29 '18 at 14:14

1 Answers1

1

No need for avoiding git pull: since Git 2.9, type:

git config --global pull.rebase true
git config --global rebase.autoStash true

Then a simple git pull will do, in essence, what your better workflow is about: rebase if needed your current branch on top of the fetched origin/yourBranch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • One reason to avoid doing this is given [here](https://stackoverflow.com/q/52538050/5353461), namely a `0` exit status even though the stash failed to reapply. – Tom Hale Dec 29 '18 at 23:14