Re: Caution when removing git branches

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Caution when removing git branches
Date: 2011-01-26 17:47:08
Message-ID: AANLkTimGg5bGKc6gzKqjU6bYwWu6BXgD0iRaDAevegNf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 26, 2011 at 12:07 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Robert Haas wrote:
>> On Wed, Jan 26, 2011 at 11:49 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> > Robert Haas wrote:
>> >> On Wed, Jan 26, 2011 at 11:26 AM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> >> > For those of you using git, I wanted to point out that it is fairly easy
>> >> > to remove git branches. ?For example, I can easily remove a branch on
>> >> > my github repository using:
>> >> >
>> >> > ? ? ? ?$ git branch -d :branch_name
>> >> >
>> >> > I don't believe that is revertable. ?What is scarey is that this could
>> >> > be done on our 'origin' as well.
>> >>
>> >> The colon in that syntax is flat wrong. ?But branch deletes won't
>> >
>> > Sorry, I was wrong. ?The syntax is:
>> >
>> > ? ? ? ?pggit push github :branch_name
>> >
>> > which is even easier to mistype.
>>
>> Yeah, true.  It's good to avoid inserting a spurious colon there.
>> Fortunately, that only removes it from the *remote* side, so in the
>> event that you want to put it back, you can just rerun the command
>> without the colon.
>
> I would love to know who thought that magic colon was a good idea?  Is
> its use even logical there?

The logic of it is that you can do this:

git push github localbranchname:remotebranchname

This takes the local branch called "localbranchname" and pushes it to
the remote repository under the name "remotebranchname", so the local
and remote sides needn't match.

If you simply write:

git push github branchname

...then the branchname is used as both the local and remote branch
names, which is usually what you want, since it's typical to call the
branch the same thing everywhere.

In the case where you want to delete a branch, you leave the local
name empty, meaning "push <nothing> on my side to remotebranchname on
the remote side".

I agree it's a little funky, but it's not completely illogical.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-01-26 17:47:22 Re: ALTER TYPE 3: add facility to identify further no-work cases
Previous Message David E. Wheeler 2011-01-26 17:45:25 Re: [HACKERS] Seeking Mentors for Funded Reviewers