unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Caldwell <david@porkrind.org>
To: David Kastrup <dak@gnu.org>
Cc: Alan Mackenzie <acm@muc.de>, emacs-devel@gnu.org
Subject: Re: Git help: amending a substandard commit message in savannah.
Date: Mon, 23 Nov 2015 11:31:41 -0800	[thread overview]
Message-ID: <5653699D.3040707@porkrind.org> (raw)
In-Reply-To: <871tbh6je3.fsf@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2319 bytes --]

On 11/23/15 3:32 AM, David Kastrup wrote:
> David Caldwell <david@porkrind.org> writes:
> 
>> On 11/23/15 2:51 AM, Alan Mackenzie wrote:
>>> By the way, what happens to abandoned branches?  Does anybody do a
>>> periodic scan of branches to get rid of them?  They surely don't go away
>>> of their own accord.  If they aren't garbage collected, then the
>>> repository's list of branches will steadily fill up with useless cruft.
>>
>> I'm not sure about Savannah, but generally with git you can delete
>> remote branches with this syntax:
>>
>>    git push origin :branch_to_be_deleted
>>
>> If that is allowed, then deleting that branch and then pushing it back
>> with your amended change would effectively be the same as `git push -f`.
> 
> You glossed over one detail.  The problem is when pushing to an
> _existing_ branch, Git uses the existence of the branch to deduce that
> you actually want the reference to be refs/heads/branch_to_be_deleted .
> So you can use
> 
>     git push origin :branch_to_be_deleted
> 
> in order to delete the branch, but once it is gone, you need to do
> 
>     git push origin HEAD:refs/heads/branch_to_be_deleted
> 
> in order to recreate it (after which it is again possible to refer to it
> using just branch_to_be_deleted).

Er, what? That's not right. Once you've deleted a branch on the remote
git server you can just push it back using whatever command you created
it with in the first place. Of course the commands you gave will work,
but it's over-complicating things certainly not required. You can do
this all day:

    git push origin :branch_to_be_deleted
    git push origin branch_to_be_deleted
    git push origin :branch_to_be_deleted
    git push origin branch_to_be_deleted
    git push origin :branch_to_be_deleted
    git push origin branch_to_be_deleted
 …etc.

It's easy enough to test:

    cd /tmp
    mkdir test
    cd test
    mkdir a
    cd a
    git init
    echo a > a
    git add a
    git commit -m a
    cd ..
    git clone a b
    cd b
    git checkout -b mybranch
    echo b > b
    git add b
    git commit -m b
    git push origin mybranch
    git push origin :mybranch
    git push origin mybranch
    git push origin :mybranch
    git push origin mybranch

-David



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]

  parent reply	other threads:[~2015-11-23 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 10:51 Git help: amending a substandard commit message in savannah Alan Mackenzie
2015-11-23 11:01 ` David Caldwell
2015-11-23 11:32   ` David Kastrup
2015-11-23 12:38     ` Yuri Khan
2015-11-23 19:31     ` David Caldwell [this message]
2015-11-23 20:17       ` David Kastrup
2015-11-23 11:10 ` Artur Malabarba
2015-11-23 16:21 ` Eli Zaretskii
2015-11-23 16:27   ` Alan Mackenzie
2015-11-23 16:42   ` John Yates
2015-11-23 17:49     ` Alan Mackenzie
2015-11-23 18:31       ` David Kastrup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5653699D.3040707@porkrind.org \
    --to=david@porkrind.org \
    --cc=acm@muc.de \
    --cc=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).