# GIT PR branch
`git-pr-branch` is a command line tool designed to manage the relationship between branches and
pull-requests.
At the moment it only supports Github and Pagure, but other backends are possible.
You need to create a personal token in [your Github settings
page](https://github.com/settings/tokens) if you plan to use Github (Pagure can work without a
token). When you start the program for the first time, it will ask you for it and store it in a
configuration file.
## Cloning a repository
When contributing to a new project, one needs to clone the repository, fork it, and clone the
fork to upload the contributions in. `git pr-branch` can do these three steps for you by running:
`git pr-branch clone https://github.com/project/repo`.
The Git remote for the newly created fork will be called `fork`.
If you already have cloned the repository and just want to create and/or register your fork, you
can use: `git pr-branch add-fork`.
## Downloading pull requests
`git pr-branch pull 42` will download pull request #42 in a local branch, creating a new branch each
time the command is run. Why, you ask? Because it is common for PR authors to amend their commits
after a review instead of adding more commits, and as a reviewer it's hard to see the differences
between the code you reviewed and the new code. By creating a new branch each time, you can just
diff with the previous branch.
If you have not checked out this PR before, it will create a branch for every existing review in the
PR's history. This way it'll be easy to see what's changed between earlier reviews even if you did
not run the command at that time (this behavior is not supported on Pagure).
When you're working on the PR branch, running `git pr-branch update` or `git pr-branch up` will
download the latest version of the PR in a new branch and switch to it. It is a shortcut to running
the same command, so you don't have to remember and type in the PR number again.
## Displaying branches and pull requests
`git pr-branch show` will list all your local branches and show you whether they are associated with
a pull request, whether that PR is still open or not, and the URL for that PR.
## Purging branches
`git pr-branch purge` will delete the branches that are linked to a closed pull request (or multiple
pull requests that are all closed). This will let you keep your local repo tidy.
## Options
If the remote name for the repository you're forking from (here called "upstream") is not named
"origin", you can set which remote is your upstream with the `-u` or `--upstream` option. Here is an
example: if Bob wants to fork Alice's repository he may clone his own fork first and then add
Alice's repository as a remote:
$ git clone git@github.com:/bob/repo
$ git remote add upstream git@github.com:/alice/repo
The original repository is therefore not in the default `origin` remote but in the `upstream` remote.
In this configuration, `git-pr-branch` must be used with the `-u` option as such:
$ git pr-branch -u upstream show
The value will be set in the local repository's configuration and you won't need to use the option
in the future.
If most of your local repositories don't use the remote `origin` as upstream, you can configure a
different default value in the configuration file. The first-time setup "wizard" will ask you.
## Installation
You can install git-pr-branch from PyPI with:
pipx install git-pr-branch
There is also a [COPR repository](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/)
that provides RPMs for some distributions.
[![Copr build status](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/package/git-pr-branch/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/package/git-pr-branch/)
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/abompard/git-pr-branch",
"name": "git-pr-branch",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.7",
"maintainer_email": null,
"keywords": "git, github",
"author": "Aur\u00e9lien Bompard",
"author_email": "aurelien@bompard.org",
"download_url": "https://files.pythonhosted.org/packages/2f/50/4dd6198c913e78d1193188981486dda2950ee14064669b67827cf9f6642d/git_pr_branch-0.1.0.tar.gz",
"platform": null,
"description": "# GIT PR branch\n\n`git-pr-branch` is a command line tool designed to manage the relationship between branches and\npull-requests.\n\nAt the moment it only supports Github and Pagure, but other backends are possible.\n\nYou need to create a personal token in [your Github settings\npage](https://github.com/settings/tokens) if you plan to use Github (Pagure can work without a\ntoken). When you start the program for the first time, it will ask you for it and store it in a\nconfiguration file.\n\n## Cloning a repository\n\nWhen contributing to a new project, one needs to clone the repository, fork it, and clone the\nfork to upload the contributions in. `git pr-branch` can do these three steps for you by running:\n`git pr-branch clone https://github.com/project/repo`.\nThe Git remote for the newly created fork will be called `fork`.\n\nIf you already have cloned the repository and just want to create and/or register your fork, you\ncan use: `git pr-branch add-fork`.\n\n## Downloading pull requests\n\n`git pr-branch pull 42` will download pull request #42 in a local branch, creating a new branch each\ntime the command is run. Why, you ask? Because it is common for PR authors to amend their commits\nafter a review instead of adding more commits, and as a reviewer it's hard to see the differences\nbetween the code you reviewed and the new code. By creating a new branch each time, you can just\ndiff with the previous branch.\n\nIf you have not checked out this PR before, it will create a branch for every existing review in the\nPR's history. This way it'll be easy to see what's changed between earlier reviews even if you did\nnot run the command at that time (this behavior is not supported on Pagure).\n\nWhen you're working on the PR branch, running `git pr-branch update` or `git pr-branch up` will\ndownload the latest version of the PR in a new branch and switch to it. It is a shortcut to running\nthe same command, so you don't have to remember and type in the PR number again.\n\n## Displaying branches and pull requests\n\n`git pr-branch show` will list all your local branches and show you whether they are associated with\na pull request, whether that PR is still open or not, and the URL for that PR.\n\n## Purging branches\n\n`git pr-branch purge` will delete the branches that are linked to a closed pull request (or multiple\npull requests that are all closed). This will let you keep your local repo tidy.\n\n## Options\n\nIf the remote name for the repository you're forking from (here called \"upstream\") is not named\n\"origin\", you can set which remote is your upstream with the `-u` or `--upstream` option. Here is an\nexample: if Bob wants to fork Alice's repository he may clone his own fork first and then add\nAlice's repository as a remote:\n\n $ git clone git@github.com:/bob/repo\n $ git remote add upstream git@github.com:/alice/repo\n\nThe original repository is therefore not in the default `origin` remote but in the `upstream` remote.\nIn this configuration, `git-pr-branch` must be used with the `-u` option as such:\n\n $ git pr-branch -u upstream show\n\nThe value will be set in the local repository's configuration and you won't need to use the option\nin the future.\n\nIf most of your local repositories don't use the remote `origin` as upstream, you can configure a\ndifferent default value in the configuration file. The first-time setup \"wizard\" will ask you.\n\n## Installation\n\nYou can install git-pr-branch from PyPI with:\n\n pipx install git-pr-branch\n\nThere is also a [COPR repository](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/)\nthat provides RPMs for some distributions.\n\n[![Copr build status](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/package/git-pr-branch/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/abompard/git-pr-branch/package/git-pr-branch/)\n",
"bugtrack_url": null,
"license": "GPL-3.0-or-later",
"summary": "A command line tool to manage the relationship between branches and pull-requests.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://gitlab.com/abompard/git-pr-branch",
"Repository": "https://gitlab.com/abompard/git-pr-branch"
},
"split_keywords": [
"git",
" github"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4dc4f412991fda1239e290792eb0e03abe711906a12ecdea6a8bc801512f0b44",
"md5": "92c10a33f7af4dcca6610c36dd39fa79",
"sha256": "fefeee77bc0103cd133ac37a8c175371584142d20f499712598e4f80f2949bc2"
},
"downloads": -1,
"filename": "git_pr_branch-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "92c10a33f7af4dcca6610c36dd39fa79",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.7",
"size": 28851,
"upload_time": "2024-06-30T06:11:50",
"upload_time_iso_8601": "2024-06-30T06:11:50.495166Z",
"url": "https://files.pythonhosted.org/packages/4d/c4/f412991fda1239e290792eb0e03abe711906a12ecdea6a8bc801512f0b44/git_pr_branch-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2f504dd6198c913e78d1193188981486dda2950ee14064669b67827cf9f6642d",
"md5": "16b992695aca3266c4c8956499d68daf",
"sha256": "302c996fb4df971c026ffcd377925d4c9e9c411e6919a8a1d6844fdbb52cc561"
},
"downloads": -1,
"filename": "git_pr_branch-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "16b992695aca3266c4c8956499d68daf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.7",
"size": 25889,
"upload_time": "2024-06-30T06:11:52",
"upload_time_iso_8601": "2024-06-30T06:11:52.144482Z",
"url": "https://files.pythonhosted.org/packages/2f/50/4dd6198c913e78d1193188981486dda2950ee14064669b67827cf9f6642d/git_pr_branch-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-30 06:11:52",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "abompard",
"gitlab_project": "git-pr-branch",
"lcname": "git-pr-branch"
}