Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.rst #63

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion NEWS.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
News
====

0.1.1

*Release date: March 28, 2012*

* Fix issue #1 which makes the git-sweep help menus more useful
* Fix a minor grammar issue in the help
* Fix issue #2 which dropped extra options when telling you to use
cleanup
* Added a --force option to skip confirmation prompt

0.1.0
-----

*Release date: 0.1.0*
*Release date: n/a*

* Initial release
135 changes: 76 additions & 59 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
=========
git-sweep
=========

A command-line tool that helps you clean up Git branches that have been merged
into master.
📚 Overview
-----------

One of the best features of Git is cheap branches. There are existing branching
models like `GitHub Flow`_ and Vincent Driessen's `git-flow`_ that describe
methods for using this feature.
Feature branches are meant to be short-lived and merged into ``master`` once they are completed. However, after merging users often forget to delete these branches, and over time, forgotten branches can build up and create **a long and messy list of branches that are no longer needed**.

The problem
-----------
``git-sweep`` is a command-line tool that helps you clean up and **safely remove remote branches that have been merged into** ``master``.

Your ``master`` branch is typically where all your code lands. All features
branches are meant to be short-lived and merged into ``master`` once they are
completed.
For more information on Git branches, models such as `GitHub Flow`_ and Vincent Driessen's `git-flow`_, describe methods for using them.

As time marches on, you can build up **a long list of branches that are no
longer needed**. They've been merged into ``master``, what do we do with them
now?
.. contents:: **Table of Contents**

The answer
----------
🔗 Dependencies
------------

Using ``git-sweep`` you can **safely remove remote branches that have been
merged into master**.
* Git >= 1.7
* Python >= 2.6

To install it run:
🔧 Installation
------------

To install ``git-sweep``, ensure Python has been installed, then open the command-line and run the following prompt:

::

pip install git-sweep || easy_install git-sweep

Try it for yourself (safely)
----------------------------

To see a list of branches that git-sweep detects are merged into your master branch:
🚀 Getting Started
-------------------

You need to have your Git repository as your current working directory.
To use ``git-sweep``, first change the current working directory to the Git repository that will be cleaned:

::

$ cd myrepo

The ``preview`` command doesn't make any changes to your repo.
Preview Command
~~~~~~~~~~~~~~~

The ``preview`` command allows you to preview what ``git-sweep`` would delete with the ``cleanup`` command. It tells ``git-sweep`` to detect all branches merged into the master branch and print them as a list. It does not alter the repository:

::

Expand All @@ -58,8 +57,10 @@ The ``preview`` command doesn't make any changes to your repo.

To delete them, run again with `git-sweep cleanup`

If you are happy with the list, you can run the command that deletes these
branches from the remote, ``cleanup``:
Cleanup Command
~~~~~~~~~~~~~~~

The ``cleanup`` command will tell ``git-sweep`` to delete all remote branches merged with ``master``. Before deleting, it will print the branches it will delete and ask for your confirmation. Upon approval ``git-sweep`` will delete the branches from the remote repository:

::

Expand Down Expand Up @@ -87,47 +88,61 @@ branches from the remote, ``cleanup``:

*Note: this can take a little time, it's talking over the tubes to the remote.*

You can also give it a different name for your remote and master branches.

::
⚙️ Options
-------

$ git-sweep preview --master=develop --origin=github
...
Skipping Branches
~~~~~~~~~~~~~~~~~

Tell it to skip the ``git fetch`` that it does by default.
The ``--skip`` option allows you to skip specified branches when using the ``preview`` or ``cleanup`` commands.

::

$ git-sweep preview --nofetch
$ git-sweep preview --skip=develop
Fetching from the remote
These branches have been merged into master:

branch1
important-upgrade
upgrade-libs
derp-removal

To delete them, run again with `git-sweep cleanup --nofetch`
To delete them, run again with `git-sweep cleanup --skip=develop`

Deleting Local Branches
~~~~~~~~~~~~~~~~~~~~~~~

To delete local branches, use the ``--origin=local`` option:

Make it skip certain branches.
::

$ cd myrepo
$ git remote add local $(pwd)
$ git-sweep cleanup --origin=local

Skipping Git Fetch
~~~~~~~~~~~~~~~~~~

By default, ``git-sweep`` will first fetch from the remote repository when using ``preview`` or ``cleanup``. You can skip this step by using the ``--nofetch`` option:

::

$ git-sweep preview --skip=develop
Fetching from the remote
$ git-sweep preview --nofetch
These branches have been merged into master:

important-upgrade
upgrade-libs
derp-removal
branch1

To delete them, run again with `git-sweep cleanup --skip=develop`
To delete them, run again with `git-sweep cleanup --nofetch`

Once git-sweep finds the branches, you'll be asked to confirm that you wish to
delete them.
Forced Delete
~~~~~~~~~~~~~

By default, before ``git-sweep`` begins deleting branches, it will ask for your confirmation:

::

Delete these branches? (y/n)

You can use the ``--force`` option to bypass this and start deleting
immediately.
You can use the ``--force`` option to bypass this and start deleting immediately.

::

Expand All @@ -147,15 +162,23 @@ immediately.

Tell everyone to run `git fetch --prune` to sync with this remote.
(you don't have to, yours is synced)

Renaming Branches
~~~~~~~~~~~~~~~~~

Using the following options, you can give the remote and master branches different names.

::

$ git-sweep preview --master=develop --origin=github
...

Development
🛠️ Development
-----------

git-sweep uses `git-flow`_ for development and release cylces. If you want to
hack on this with us, fork the project and put a pull request into the
``develop`` branch when you get done.
If you want to hack on this with us, fork the project and create a pull request in the ``develop`` branch when you are finished.

To run the tests, bootstrap Buildout and run this command:
``git-sweep`` uses `git-flow`_ for development and release cycles. To run the tests, bootstrap Buildout and run this command:

::

Expand All @@ -167,22 +190,16 @@ To run the tests, bootstrap Buildout and run this command:
...
$ ./bin/test

We also use Tox_. It will run the tests for Python 2.6 and 2.7.
We also use Tox_. Run the tests for Python 2.6 and 2.7 using the following command:

::

$ ./bin/tox

Requirements
------------

* Git >= 1.7
* Python >= 2.6

License
📃 License
-------

Friendly neighborhood MIT license.
* Just a friendly neighborhood MIT license.

.. _GitHub Flow: http://scottchacon.com/2011/08/31/github-flow.html
.. _git-flow: http://nvie.com/posts/a-successful-git-branching-model/
Expand Down
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
README = open(os.path.join(here, 'README.rst')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()

version = '0.1.0'
version = '0.1.1'

install_requires = [
'GitPython>=0.3.2RC1']
Expand All @@ -20,7 +20,17 @@
description="Clean up branches from your Git remotes",
long_description=README + '\n\n' + NEWS,
classifiers=[
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
'Development Status :: 4 - Beta',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Natural Language :: English',
'Operating System :: POSIX',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Version Control',
'Topic :: Text Processing'
],
keywords='git maintenance branches',
author='Arc90, Inc.',
Expand Down