Suggestion: git fetch <remote> <branch> to update remote-tracking branch
From: Antony Male <hidden>
Date: 2016-06-15 22:53:13
Hi all, First off, this is a very tentative suggestion. It would result in a slight change to established behaviour, which I'm well aware could be a Bad Thing(tm). However, I was encouraged by a number of people on #git to make it anyway, so here goes. The issue is this: the two-argument form of 'git fetch' (e.g. 'git fetch <remote> <branch>') fetches the named ref into FETCH_HEAD, but does not update the related remote-tracking branch. While this is intuitive behaviour when <remote> is a URL, we see a lot of git beginners attempting to run 'git fetch origin branch' and being confused when origin/branch isn't updated. Similarly, 'git pull origin master' will, in a simple case, fast-forward the local master but not origin/master. My suggestion, therefore, is to modify the behaviour of 'git fetch' such that 'git fetch <remote> <branch>' will update both FETCH_HEAD and the relevant remote-tracking branch, when <remote> is the name of a configured remote and <branch> contains only the src part of the refspec. The behaviour would not change when <remote> was a URL or path, or when a <src>:<dst> refspec was used. Of course, it would be desirable to be able to replicate the existing behaviour. Currently, I don't have any good suggestions, although there may be an existing trick I'm missing. Possible suggestions might be 'git fetch <remote> <branch>:FETCH_HEAD' or 'git fetch <remote> <branch>:', or maybe a new flag? What do people think? Many thanks for your time and consideration, Antony Male