Re: best git practices, was Re: Git User's Survey 2007 unfinished summary continued

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Steffen Prohaska wrote:

On Oct 25, 2007, at 10:18 PM, Andreas Ericsson wrote:

Junio C Hamano wrote:
Andreas Ericsson <ae@xxxxxx> 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 it would be better to implement it as a different command that
would do all those weird and tedious dwim things that suit a particular
kind of developer, but only so long as those operations succeed without
conflicts.

So for example the flow could go something like this;
---
read_branch_merge_config();

git fetch

if prefetch(local == remote_tracking)
	set ref local to match ref remote_tracking;
else if (--safe-rebase)
	try_rebase local onto remote_tracking;
---

It's such a common operation that I really do think it's worth
having support for it. Perhaps with a "--try-rebase" option to
git-pull.

If we then add a a "--push-after-pull" (to work on the current
branch only) we have the "git sync" alias readily available to
accommodate the average reluctant git user, and I'm sure gui
hackers could do wonders with it, especially on windows, where
people seem accustomed to a lot of things happening when clicking
a single button.

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.


Yup, and it can be done with a post-checkout hook (which I notice
there are no examples for, so I've added that to my ever-growing
todo).

--
Andreas Ericsson                   andreas.ericsson@xxxxxx
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux