emacs-devel
[Top][All Lists]
Advanced

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

Re: Git help: amending a substandard commit message in savannah.


From: David Caldwell
Subject: Re: Git help: amending a substandard commit message in savannah.
Date: Mon, 23 Nov 2015 11:31:41 -0800
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Thunderbird/42.0

On 11/23/15 3:32 AM, David Kastrup wrote:
> David Caldwell <address@hidden> 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: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]