How to 'delete' a topic branch?

1,121 views
Skip to first unread message

Cliff Spradlin

unread,
Oct 23, 2008, 7:07:08 PM10/23/08
to Repo and Gerrit Discussion
Once I've started a topic branch, is there an easy way to sync the
whole repo back to its initial state (or the latest of the main
trunk)?

-cliff

Shawn Pearce

unread,
Oct 23, 2008, 7:11:48 PM10/23/08
to repo-d...@googlegroups.com

Every repository has a m/master branch that represents the master branch from the manifest.  That's the upstream accepted code.  So:

  git checkout m/master

in any project will get you back to that version, at any time, leaving your branch in place.

You can delete any branches which have already been submitted *and* merged by doing a sync and a prune with repo:

  repo sync
  repo prune

To delete other topic branches, like to discard a flawed experiment, you'll need to checkout something else (e.g. m/master like above) and then use "git branch -d branchname" to remove the branch.  repo prune is careful to only remove branches which have been fully merged into the project and are widely distributed around the world.

Cliff Spradlin

unread,
Oct 23, 2008, 7:54:29 PM10/23/08
to Repo and Gerrit Discussion
repo prune seemed to do exactly what I wanted. I must have missed
that, thanks!

-cliff

On Oct 23, 4:11 pm, "Shawn Pearce" <s...@google.com> wrote:

Shawn Pearce

unread,
Oct 23, 2008, 7:56:24 PM10/23/08
to repo-d...@googlegroups.com
On Thu, Oct 23, 2008 at 16:54, Cliff Spradlin <cliff_s...@htc.com> wrote:

repo prune seemed to do exactly what I wanted. I must have missed
that, thanks!

Docs on repo are still a little slim, but "repo" by itself gives you available commands and "repo help cmd" gives you (some) documentation on that command's usage and what it does.

Christopher Tate

unread,
Oct 23, 2008, 8:45:13 PM10/23/08
to repo-d...@googlegroups.com
(Forgive the ignorant questions; i'm still wrapping my head around git)

So it sounds like "repo prune" is effectively "i'm done with this topic branch and have uploaded all of the changes I'm going to; now I want to stop using this topic branch and go on to a new one."  Is that a fair interpretation?

What if you get partway into some edits and want to abandon them and get back to the state as of when you started the topic branch?  That's what 'git reset' is for, right?

--
chris

Shawn Pearce

unread,
Oct 23, 2008, 8:49:44 PM10/23/08
to repo-d...@googlegroups.com
On Thu, Oct 23, 2008 at 17:45, Christopher Tate <ct...@google.com> wrote:
(Forgive the ignorant questions; i'm still wrapping my head around git)

I'm sure there will be many more, from many people... git is not just a version control system, its a version control "toolkit" so you can build your own... like we (sort of) did with repo.  Anyway...
 
So it sounds like "repo prune" is effectively "i'm done with this topic branch and have uploaded all of the changes I'm going to; now I want to stop using this topic branch and go on to a new one."  Is that a fair interpretation?

Yes, but with two corrections:

- It cleans up all topic branches, not just the current one.
- It only cleans up topics that have actually been merged.  If the change is uploaded that isn't sufficient to be pruned.  So it only deletes topic branches where the changes are already published for the whole world to get, and are part of the permanent history of the project.
 
What if you get partway into some edits and want to abandon them and get back to the state as of when you started the topic branch?  That's what 'git reset' is for, right?

Yes.  Or you can just checkout the manifest revision ("git checkout m/master") to leave the branch and go back to the official version.

Reply all
Reply to author
Forward
0 new messages