From 533727b37331402e6bb11bf90c4913f2abd4540b Mon Sep 17 00:00:00 2001 From: robmadole Date: Mon, 26 Mar 2012 08:45:14 -0500 Subject: [PATCH 1/4] Version up --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ec75d8f..0395a57 100644 --- a/setup.py +++ b/setup.py @@ -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'] From 6f518a36fd7e4cf8ff84f1045d36538999c6a579 Mon Sep 17 00:00:00 2001 From: robmadole Date: Wed, 28 Mar 2012 08:04:44 -0500 Subject: [PATCH 2/4] Updating news and adding classifiers --- NEWS.txt | 12 +++++++++++- setup.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/NEWS.txt b/NEWS.txt index c3784ef..0dfd33f 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -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 diff --git a/setup.py b/setup.py index 0395a57..e5483d8 100644 --- a/setup.py +++ b/setup.py @@ -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.', From 7d6e85a9b6c3df0452de05f1605ed0071130495f Mon Sep 17 00:00:00 2001 From: Anton Vlasenko Date: Mon, 22 Sep 2014 12:29:53 +0300 Subject: [PATCH 3/4] Describing hack how to clean up local branches --- README.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.rst b/README.rst index 5414eb6..3fd0286 100644 --- a/README.rst +++ b/README.rst @@ -147,6 +147,19 @@ immediately. Tell everyone to run `git fetch --prune` to sync with this remote. (you don't have to, yours is synced) + + +Deleting local branches +----------- + +You can also clean up local branches by using simple hack: + +:: + + $ cd myrepo + $ git remote add local $(pwd) + $ git-sweep cleanup --origin=local + Development ----------- From 90bd3900da4757427912ca485a87358a9ea676cd Mon Sep 17 00:00:00 2001 From: Stephen Ng <73617325+sng125@users.noreply.github.com> Date: Sun, 1 Oct 2023 19:45:22 -0400 Subject: [PATCH 4/4] Updated README.rst - Altered the overview to help readers better understand the project's purpose - Merged the Problem and Solution sections into the primary overview - Added a table of contents - Added an Installation section - Separated each feature and corresponding example into its own subsection to improve readability - Improved the explanations for each feature --- README.rst | 140 +++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 68 deletions(-) diff --git a/README.rst b/README.rst index 3fd0286..77652c5 100644 --- a/README.rst +++ b/README.rst @@ -1,48 +1,47 @@ +========= git-sweep ========= -A command-line tool that helps you clean up Git branches that have been merged -into master. +📚 Overview +----------- + +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**. -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. +``git-sweep`` is a command-line tool that helps you clean up and **safely remove remote branches that have been merged into** ``master``. -The problem ------------ +For more information on Git branches, models such as `GitHub Flow`_ and Vincent Driessen's `git-flow`_, describe methods for using them. -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. +.. contents:: **Table of Contents** -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? +🔗 Dependencies +------------ -The answer ----------- +* Git >= 1.7 +* Python >= 2.6 -Using ``git-sweep`` you can **safely remove remote branches that have been -merged into master**. +🔧 Installation +------------ -To install it run: +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: :: @@ -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: :: @@ -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: + +:: + + $ cd myrepo + $ git remote add local $(pwd) + $ git-sweep cleanup --origin=local + +Skipping Git Fetch +~~~~~~~~~~~~~~~~~~ -Make it skip certain branches. +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` + +Forced Delete +~~~~~~~~~~~~~ -Once git-sweep finds the branches, you'll be asked to confirm that you wish to -delete them. +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. :: @@ -148,27 +163,22 @@ immediately. Tell everyone to run `git fetch --prune` to sync with this remote. (you don't have to, yours is synced) - -Deleting local branches ------------ +Renaming Branches +~~~~~~~~~~~~~~~~~ -You can also clean up local branches by using simple hack: +Using the following options, you can give the remote and master branches different names. -:: +:: - $ cd myrepo - $ git remote add local $(pwd) - $ git-sweep cleanup --origin=local - + $ 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: :: @@ -180,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/