# Re: Rationale for the "Never commit to the right side of a Pull line" rule

5 messages from 2006-10-26 to 2006-10-27. Participants: Jakub Narebski, Karl Hasselström, Jerome Lovy, Luben Tuikov, Linus Torvalds.
Thread: https://gitlist.dev/t/43403

## Jerome Lovy, 2006-10-26 16:47

Subject: Rationale for the "Never commit to the right side of a Pull line" rule
Message-ID: <ehqp1u$j4$1@sea.gmane.org>
URL: https://gitlist.dev/e/ehqp1u%24j4%241%40sea.gmane.org

```
Hi,

Could someone please point me to / give me the rationale for the "Never 
commit to the right side of a Pull line" rule ?

I found the rule in the second Note of the git-fetch man-page (eg 
http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html).

It's been taken over in _bold letters_ by X.Org/freedesktop.org in their 
"UsingGit" document (http://freedesktop.org/wiki/UsingGit).

In both places though, I don't see any explanation, but rather a 
commandment ;-) . Am I missing the ovious ?

My candid thoughts: to me the practice recommended here seems 
subjectively "cleaner" indeed, but is it objectively better or even 
essential? Why?

TIA
Jérôme

```

## Linus Torvalds, 2006-10-26 17:11

Subject: Re: Rationale for the "Never commit to the right side of a Pull line" rule
Message-ID: <Pine.LNX.4.64.0610261003590.3962@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0610261003590.3962%40g5.osdl.org
In-Reply-To: <ehqp1u$j4$1@sea.gmane.org>

```


On Thu, 26 Oct 2006, Jerome Lovy wrote:
> 
> Could someone please point me to / give me the rationale for the "Never commit
> to the right side of a Pull line" rule ?

It's not a technical rule per se.

It's just a way to avoid what will almost inevitably otherwise be a 
horribly horribly confusing situation.

I say "almost inevitably", because if you really have worked with git 
enough, and understand how it works on a very fundamental level, there are 
actually no problems at all with doing so, and maybe you could have 
perfectly fine reasons to break the rule, and commit to a branch that is 
officially "maintained in another repository" and then push it out.

But it's a good rule in general, just because it makes a certain common 
workflow explicit. In fact, we really probably should start to always use 
the "refs/remote/origin/HEAD" kind of syntax by default, where you can't 
even _switch_ to the branch maintained in the remote repository, because 
it's not a real branch locally.

So normally you should consider the "origin" branch to be a pointer to 
WHAT YOU FETCHED LAST - and that implies that you shouldn't commit to it, 
because then it loses that meaning (now it's "what you fetched last and 
then committed your own work on top of", which is something totally 
different).


```

## Karl Hasselström, 2006-10-26 17:26

Subject: Re: Rationale for the "Never commit to the right side of a Pull line" rule
Message-ID: <20061026172603.GA21256@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20061026172603.GA21256%40diana.vm.bytemark.co.uk
In-Reply-To: <Pine.LNX.4.64.0610261003590.3962@g5.osdl.org>

```
On 2006-10-26 10:11:50 -0700, Linus Torvalds wrote:

> But it's a good rule in general, just because it makes a certain
> common workflow explicit. In fact, we really probably should start
> to always use the "refs/remote/origin/HEAD" kind of syntax by
> default, where you can't even _switch_ to the branch maintained in
> the remote repository, because it's not a real branch locally.

Seconded. I really like having remote branches in their own namespace
where I can't confuse them with my local branches by mistake -- and
that the branches of different remotes end up in different separate
namespaces.

> So normally you should consider the "origin" branch to be a pointer
> to WHAT YOU FETCHED LAST - and that implies that you shouldn't
> commit to it, because then it loses that meaning (now it's "what you
> fetched last and then committed your own work on top of", which is
> something totally different).

Defaulting to --use-separate-remotes would mean not having to explain
this to every single confused new user. :-)

It feels like the right thing to do, because it reduces the amount of
things a user has to know about git internals. Until you get to the
level where you can do brain surgery on your repo, the remotes/
branches will really _be_ your local read-only mirror of remote
branches, and you don't have to be aware of the possibility that they
could get out of sync because of local commits.

-- 
Karl Hasselström, kha@treskal.com

```

## Jakub Narebski, 2006-10-26 17:30

Subject: Re: Rationale for the "Never commit to the right side of a Pull line" rule
Message-ID: <ehqr9t$9rh$1@sea.gmane.org>
URL: https://gitlist.dev/e/ehqr9t%249rh%241%40sea.gmane.org
In-Reply-To: <ehqp1u$j4$1@sea.gmane.org>

```
Jerome Lovy wrote:

> Could someone please point me to / give me the rationale for the "Never 
> commit to the right side of a Pull line" rule ?
> 
> I found the rule in the second Note of the git-fetch man-page (eg 
> http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html).

Because git refuses to fetch into branch on top of which there are changes
which are not present in the branch you fetch from (if it is not
fast-forward case). So commitiing to tracking branches breaks the most
typical workflow, i.e. fetch when you want, push when you are ready.

git-clone --use-separate-remotes takes care of that by putting tracking
branches in refs/remotes/, i.e. outside refs/heads/, so you cannot commit
there, at least not by accident.
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


```

## Luben Tuikov, 2006-10-27 08:56

Subject: Re: Rationale for the "Never commit to the right side of a Pull line" rule
Message-ID: <546144.34624.qm@web31811.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/546144.34624.qm%40web31811.mail.mud.yahoo.com
In-Reply-To: <ehqp1u$j4$1@sea.gmane.org>

```
--- Jerome Lovy <t2a2e9z8ncbs9qg@brefemail.com> wrote:
> Hi,
> 
> Could someone please point me to / give me the rationale for the "Never 
> commit to the right side of a Pull line" rule ?
> 
> I found the rule in the second Note of the git-fetch man-page (eg 
> http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html).
> 
> It's been taken over in _bold letters_ by X.Org/freedesktop.org in their 
> "UsingGit" document (http://freedesktop.org/wiki/UsingGit).
> 
> In both places though, I don't see any explanation, but rather a 
> commandment ;-) . Am I missing the ovious ?

Yes, you are missing the obvious and yes it is explained.
Read the 2nd "Note" for the documentation of "git-fetch":

http://www.kernel.org/pub/software/scm/git/docs/git-fetch.html

Quoted here for convenience:

[NOTE]
You never do your own development on branches that appear
on the right hand side of a <refspec> colon on `Pull:` lines;
they are to be updated by `git-fetch`.  If you intend to do
development derived from a remote branch `B`, have a `Pull:`
line to track it (i.e. `Pull: B:remote-B`), and have a separate
branch `my-B` to do your development on top of it.  The latter
is created by `git branch my-B remote-B` (or its equivalent `git
checkout -b my-B remote-B`).  Run `git fetch` to keep track of
the progress of the remote side, and when you see something new
on the remote branch, merge it into your development branch with
`git pull . remote-B`, while you are on `my-B` branch.
The common `Pull: master:origin` mapping of a remote `master`
branch to a local `origin` branch, which is then merged to a
local development branch, again typically named `master`, is made
when you run `git clone` for you to follow this pattern.

  Luben


> 
> My candid thoughts: to me the practice recommended here seems 
> subjectively "cleaner" indeed, but is it objectively better or even 
> essential? Why?
> 
> TIA
> Jérôme
> 
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

```
