Re: best git practices, was Re: Git User's Survey 2007 unfinished summary continued
- From
Steffen Prohaska <prohaska@zib.de>
- Date
- Oct 26, 2007, 06:18 UTC
- Message-ID
- <D38E4717-CF67-4897-983E-2B45CA217C11@zib.de>
- In-Reply-To
- <4720FA00.1050805@op5.se>
On Oct 25, 2007, at 10:18 PM, Andreas Ericsson wrote:
Show 39 quoted lines
> Junio C Hamano wrote: >> Andreas Ericsson <ae@op5.se> writes: > >> With that in mind, how about making "git checkout foo", after >> foo is set up thusly, to show: >> git log --pretty=oneline --left-right origin/pu...foo >> if (and only if) they have diverged? Then you can deal with the >> staleness of local tracking fork 'foo' in any way you want. >> You could even go one step further and make this "checkout foo", >> in addition to or instead of showing the above left-right log, >> - automatically run "git merge origin/pu" if it is a >> fast-forward, and say it did _not_ run that merge if it is >> not a fast-forward; >> - automatically run "git merge origin/pu" always, even if it is >> not a fast-forward; >> - automatically run "git rebase origin/pu" always; >> Would that make your life easier? > > That it would, except the confusion would then be that it's > automatically > rebased for the branches one currently hasn't got checked out while > pulling, > and the branch that *is* checked out gets merged (crazy, yes), so > those > who prefer the rebase would get what they want by doing something > completely > bonkers, such as: > > git checkout -b just-gonna-pull HEAD^ > git pull > git checkout whatever-other-branch-they-were-on > > (yes, "aggresively ignorant", I think Ted said in an earlier mail) > > It'd probably be better to go with Dscho's suggestion, although I'm > not quite > sure what that was any more. It involved automagical rebasing on > fetch or pull > though.
git pull's automagic and the automatic behaviour of git checkout proposed by Junio should always do the same. git pull should be changed to act a if your three commands were fused into it (but obviously implemented differently).
I think teaching "git checkout" a dwim mode is quite interesting. The required work to bring a local branch up-to-date with a remote branch is deferred until really needed. An then "git checkout" does the right thing. A lot of automagic but definitely intriguing.
Steffen