Re: [git-users] How to remove remote branch completely

2016-07-29 Thread 'Konstantin Khomoutov' via Git for human beings
On Thu, 28 Jul 2016 09:37:00 -0700 (PDT)
Valencia  wrote:

> I have 2 branches in my repo. I am done with most of the code
> changes. Therefore, I want keep just one branch on my repo. How do I
> completely remove a remote branch. 
> 
> I read online that we can use "git branch -d , to delete
> branches, however, the git history remains intact. But I need to
> clear the history also. 
> 
> If anyone could help me with this issue then it would be great.

Well, I'm pretty sure this is covered in any Git book, so I'd really
advise you to read one.

Git has somewhat geeky approach to removing "refs" (heads (branches)
and tags) in remote repositories: you have to "push nothing" to a ref
to delete it.
To explain, consider how you push.

To begin with, the command

  $ git push origin foo:bar

would first resolve the local name "bar", then resolve the name "bar"
in the remote repository known as "origin" and then try to update
whatever is named "bar" in that repository with the history reachable
from whatever is named "foo" in our local repository.
The rules of resolving ref names are covered in the "gitrevisions"
manual page (run `git help revisions` read it).

Now you could be more specific.  Say, to push a branch (head) "foo" to a
tag "bar", you'd call:

  $ git push origin refs/heads/foo:refs/tags/bar

This is needed if there is any confusion of the resolution of a
particular ref.

The whole "foo:bar" or "refs/heads/foo:refs/tags/bar" thing is called
"the refspec" in Git's parlance, which stems from "ref specification".

OK, so you want to "push nothing" to a remote ref to delete it.
To do that, you just omit the lef-hand side of the respec, so

  $ git push origin :bar

would try to delete whatever ref the name "bar" refers in the remote
repository.  If you want to be specific, do

  $ git push origin :refs/heads/bar

to delete a branch; to delete a tag, you'd use "refs/tags/".

The last bit is that if your remote repository is "known" to the local
one (as "origin" is in many cases), you'd also want to delete the so
called "remote branches" of this repository which are stored locally
(those "origin/whatever" things).  To do this, either use

  $ git branch -d -r origin/

(notice the "-r" command-line option) or run

  $ git remote prune origin

which asks the named remote "origin" about what branches it has and
deletes all the locally stored remote branches for that repository which
were tracking branches no longer present in it.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] How to remove remote branch completely

2016-07-28 Thread Philip Oakley
A little extra bit to Gergely's excellent reply. The thing about the colon (:) 
that Gergely mentioned is in fact it is the "nothing" that is to the left of 
the colon that is being pushed to the remote branch, which ultimately deletes 
it.  The colon itself is the delimiter, but it can be difficult to realise that 
is what has happened.
--
Philip
  - Original Message - 
  From: Gergely Polonkai 
  To: git-users@googlegroups.com 
  Sent: Thursday, July 28, 2016 11:02 PM
  Subject: Re: [git-users] How to remove remote branch completely


  Hello,

  when you remove a branch with git branch -d, you delete a reference to the 
commit on the tip of that branch. When all references to a commit are gone, the 
commits, thus, the history of the removed branch, will be garbage collected 
(usually after a couple of weeks). You can make this happen sooner with git gc; 
see git gc --help for more information.

  Removing a branch on a remote is as easy as pushing nothing to it, like git 
push origin :branch-to-delete. Note the colon (:); it tells Git to push nothing 
to that branch, effectively removing that reference. Again, git gc will prune 
the history sooner or later. Of course, if you have direct access to the remote 
repository, you can run git gc on that, too.

  Best,
  Gergely 



  On Jul 28, 2016 18:37, "Valencia"  wrote:

Hi All,

I have 2 branches in my repo. I am done with most of the code changes. 
Therefore, I want keep just one branch on my repo. How do I completely remove a 
remote branch.

I read online that we can use "git branch -d , to delete 
branches, however, the git history remains intact. But I need to clear the 
history also.

If anyone could help me with this issue then it would be great.

Thanks!

--
You received this message because you are subscribed to the Google Groups 
"Git for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


  -- 
  You received this message because you are subscribed to the Google Groups 
"Git for human beings" group.
  To unsubscribe from this group and stop receiving emails from it, send an 
email to git-users+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] How to remove remote branch completely

2016-07-28 Thread Gergely Polonkai
Hello,

when you remove a branch with git branch -d, you delete a reference to the
commit on the tip of that branch. When all references to a commit are gone,
the commits, thus, the history of the removed branch, will be garbage
collected (usually after a couple of weeks). You can make this happen
sooner with git gc; see git gc --help for more information.

Removing a branch on a remote is as easy as pushing nothing to it, like git
push origin :branch-to-delete. Note the colon (:); it tells Git to push
nothing to that branch, effectively removing that reference. Again, git gc
will prune the history sooner or later. Of course, if you have direct
access to the remote repository, you can run git gc on that, too.

Best,
Gergely

On Jul 28, 2016 18:37, "Valencia"  wrote:

> Hi All,
>
> I have 2 branches in my repo. I am done with most of the code changes.
> Therefore, I want keep just one branch on my repo. How do I completely
> remove a remote branch.
>
> I read online that we can use "git branch -d , to delete
> branches, however, the git history remains intact. But I need to clear the
> history also.
>
> If anyone could help me with this issue then it would be great.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.