git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Linear history *and* share a branch?

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Apr 6, 2012, 10:04 UTC
Message-ID
<CACBZZX7+cp6CwsnWmc8P1i9SabiTOJZXO9w-3E_m1A83gZKA6w@mail.gmail.com>
In-Reply-To
<CACBZZX6za0+MXi4nPiV5ZuCKa91cPz0aye6FZG4gGAdqj0GqcA@mail.gmail.com>
On Thu, Apr 5, 2012 at 22:56, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
Show 17 quoted lines
> On Thu, Apr 5, 2012 at 22:48, Hilco Wijbenga <hilco.wijbenga@gmail.com> wrote:
>> Should we simply do "git merge master" instead of "git rebase master"?
>> And then do something at the end when we are about to merge the shared
>> branch back into master to guarantee linear history? Your thoughts and
>> ideas would be greatly appreciated.
>
> Yes, that's the most sensible workflow to have. You create a topic
> branch, push/pull it back and forth, do merge commits and never rebase
> it, then when you decide if it's finished you can either merge it into
> the mainline (with non-linear history), or have someone rebase it and
> push it to the mainline.
>
> I use the latter workflow extensively in my work e.g. when peer
> programming. We'll both have the same branch set up as a tracking
> branch, make a bunch of WIP commits with crappy commit messages for a
> day or so, then at the end of the day interactively rebase the branch,
> and push it with linear history to the mainline.

To elaborate, this is how to do the workflow I'm talking about, with a git set to push.default=tracking.

The person setting up the topic branch does this, "origin" is our shared upstream server. This creates a new topic and pushes it:

    git checkout -b team-whatever/some-topic
    git push origin -u team-whatever/some-topic
Everyone else does this:
    git fetch origin
    git checkout -t team-whatever/some-topic

Then everyone hacks, and does a "git pull --no-rebase && git push" to push work. When you're pair programming and switching between computers this'll often be:

    git commit -a -m"wip"
    git push
Followed by, on the other box:
    git pull --no-rebase

Then when the topic is ready and you want to push it to the mainline someone does:

    git fetch origin
    git rebase -i origin/master
and rewords/squashes/fixes up the various commits, followed by:
    # Now fixed up, push to the mainline
    git push origin team-whatever/some-topic:master
    # Nuke the now-redundant topic branch
    git push origin --delete team-whatever/some-topic
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 3 of 7 in “Linear history *and* share a branch?”
  1. Hilco WijbengaApr 5, 2012
  2. Ævar Arnfjörð BjarmasonApr 5, 2012
  3. Ævar Arnfjörð BjarmasonApr 6, 2012
  4. Junio C HamanoApr 5, 2012
  5. Hilco WijbengaApr 5, 2012
  6. Michael WittenApr 6, 2012
  7. Neal KreitzingerApr 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.