git-branch-cleaner


Namegit-branch-cleaner JSON
Version 1.2.0 PyPI version JSON
download
home_page
SummaryConnect to git repository and delete branches which are not in remote repository from local repository
upload_time2023-01-04 00:05:28
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2022 Vishnu Gangadhara Naik Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords git branches delete
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GitBranchCleaner

GitBranchCleaner is a tool to clean up git repositories. 
This tool allows users to delete branches from a local git repository that are not present in the remote repository.
This tool is useful when you have a lot of branches in your local repository, and you want to clean up your local repository.
This tool is not intended to delete remote branches as it is not safe to do so and one might need to do a lot of manual work to recover from such a mistake.

# Installation
To use the tool first install using pip or git clone the repository and run the setup.py file:
```commandline
pip install git-branch-cleaner
```
or
```commandline
git clone https://github.com/Vishnu-Naik/git-branch-cleaner
cd git-branch-cleaner
python setup.py install
```

# Usage
This tool can be used as a command line tool or as a library. Let's see those two options in detail.

## Command Line Tool

The command line tool can be used to delete branches from a local repository that are not present in the remote repository.
The command line tool can be used as follows:

```commandline
repo_cleaner --repo <path to git repository>
```


--repo is the optional flag to the command. If this flag is not provided, the current working directory is assumed to be the git repository. 
The tool will show the branches that are on local and remote. As shown below:
```
=================================================
List of remote branches:
main
develop
feature/branch1
=================================================
List of local branches:
main
develop
feature/branch1
feature/branch2
=================================================
```
 

The tool will ask the user if they want to delete the branches that are not present in the remote repository. 
If the user enters anything else other than Y or y, the tool will end its execution. Else it will display the branches that are not present in the remote repository one after the other which are
going to be deleted and ask for confirmation before deleting each of the branches.

## Library

To use this tool as a library, you can import the GitRepoCleaner class from the git_repo_cleaner module and use it as follows:

from cleaner import git_repo_cleaner

```python
from cleaner import git_repo_cleaner

git_repo_cleaner.main('/home/username/git_repos/dummy_project')
 ```
For finer functionality, you can use the GitRepoCleaner class directly as follows:
```python
from cleaner.git_repo_cleaner import *

local_branches, remote_branches = GitRepoCleaner.get_local_and_remote_branches()
print(local_branches)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "git-branch-cleaner",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "git,branches,delete",
    "author": "",
    "author_email": "Vishnu Gangadhara Naik <vishnugnaik@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/80/46/a0e8c32e6aa9e5a9b61084ebd4113388b3e4beaa5644a0a1e90c0d185e6e/git-branch-cleaner-1.2.0.tar.gz",
    "platform": null,
    "description": "# GitBranchCleaner\r\n\r\nGitBranchCleaner is a tool to clean up git repositories. \r\nThis tool allows users to delete branches from a local git repository that are not present in the remote repository.\r\nThis tool is useful when you have a lot of branches in your local repository, and you want to clean up your local repository.\r\nThis tool is not intended to delete remote branches as it is not safe to do so and one might need to do a lot of manual work to recover from such a mistake.\r\n\r\n# Installation\r\nTo use the tool first install using pip or git clone the repository and run the setup.py file:\r\n```commandline\r\npip install git-branch-cleaner\r\n```\r\nor\r\n```commandline\r\ngit clone https://github.com/Vishnu-Naik/git-branch-cleaner\r\ncd git-branch-cleaner\r\npython setup.py install\r\n```\r\n\r\n# Usage\r\nThis tool can be used as a command line tool or as a library. Let's see those two options in detail.\r\n\r\n## Command Line Tool\r\n\r\nThe command line tool can be used to delete branches from a local repository that are not present in the remote repository.\r\nThe command line tool can be used as follows:\r\n\r\n```commandline\r\nrepo_cleaner --repo <path to git repository>\r\n```\r\n\r\n\r\n--repo is the optional flag to the command. If this flag is not provided, the current working directory is assumed to be the git repository. \r\nThe tool will show the branches that are on local and remote. As shown below:\r\n```\r\n=================================================\r\nList of remote branches:\r\nmain\r\ndevelop\r\nfeature/branch1\r\n=================================================\r\nList of local branches:\r\nmain\r\ndevelop\r\nfeature/branch1\r\nfeature/branch2\r\n=================================================\r\n```\r\n \r\n\r\nThe tool will ask the user if they want to delete the branches that are not present in the remote repository. \r\nIf the user enters anything else other than Y or y, the tool will end its execution. Else it will display the branches that are not present in the remote repository one after the other which are\r\ngoing to be deleted and ask for confirmation before deleting each of the branches.\r\n\r\n## Library\r\n\r\nTo use this tool as a library, you can import the GitRepoCleaner class from the git_repo_cleaner module and use it as follows:\r\n\r\nfrom cleaner import git_repo_cleaner\r\n\r\n```python\r\nfrom cleaner import git_repo_cleaner\r\n\r\ngit_repo_cleaner.main('/home/username/git_repos/dummy_project')\r\n ```\r\nFor finer functionality, you can use the GitRepoCleaner class directly as follows:\r\n```python\r\nfrom cleaner.git_repo_cleaner import *\r\n\r\nlocal_branches, remote_branches = GitRepoCleaner.get_local_and_remote_branches()\r\nprint(local_branches)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Vishnu Gangadhara Naik  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Connect to git repository and delete branches which are not in remote repository from local repository",
    "version": "1.2.0",
    "split_keywords": [
        "git",
        "branches",
        "delete"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0733f7aa58a19cb4f8d707a43d758150439bfaf29f23419b5ab3b9239111d2e7",
                "md5": "92fac35afe055b5772b11c3d299e2c3b",
                "sha256": "5d4dd42d77f53904d2cad3993a886e4223005b1a1d6e9f57628d8fffb47f1a0b"
            },
            "downloads": -1,
            "filename": "git_branch_cleaner-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "92fac35afe055b5772b11c3d299e2c3b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 10344,
            "upload_time": "2023-01-04T00:05:27",
            "upload_time_iso_8601": "2023-01-04T00:05:27.354539Z",
            "url": "https://files.pythonhosted.org/packages/07/33/f7aa58a19cb4f8d707a43d758150439bfaf29f23419b5ab3b9239111d2e7/git_branch_cleaner-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8046a0e8c32e6aa9e5a9b61084ebd4113388b3e4beaa5644a0a1e90c0d185e6e",
                "md5": "590e10977f06714f7557bf41750b2c7c",
                "sha256": "da86f08dd92a5c5611935f472cc49bb829447edd148ec53045a4fae51bb48a6e"
            },
            "downloads": -1,
            "filename": "git-branch-cleaner-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "590e10977f06714f7557bf41750b2c7c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 10800,
            "upload_time": "2023-01-04T00:05:28",
            "upload_time_iso_8601": "2023-01-04T00:05:28.953484Z",
            "url": "https://files.pythonhosted.org/packages/80/46/a0e8c32e6aa9e5a9b61084ebd4113388b3e4beaa5644a0a1e90c0d185e6e/git-branch-cleaner-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-04 00:05:28",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "git-branch-cleaner"
}
        
Elapsed time: 0.02674s