Skip to content

Making operating on your own fork easier (--repo improvements or a new option) #317

Description

@kiprasmel

Ported from #251 (comment) with improvements.

Describe the feature or problem you’d like to solve

A simple way to target the fork instead of the original repo with any command.

Use cases:
I have some forked repositories that I maintain & work on myself, with all intentions to target the fork's issues, PRs etc., and not the original repository.

Examples:

as you can see, these are all forks that are specific specifically to my specific use case. (lol)

There are no intentions to merge them back or interact with the original repository, except for seeing how many commits the repos have diverged, being open about the fact that the repo is forked and having it in the list of forks at the original repository etc.


Currently, with https://github.com/github/hub, I've set-up the following git aliases to allow me to have a comfortable workflow with such cases:

~/.gitconfig:

# replace `sarpik` with your github username

[alias]
	prme =        pull-request --push -a sarpik  --base        master  -epo                                                  # targets upstream
	prmee =  !hub pull-request --push -a sarpik  --base sarpik:master  -epo --head sarpik:"$(git symbolic-ref --short HEAD)" # targets origin  (your repo)
	prmed =       pull-request --push -a sarpik  --base        master -depo                                                  # targets upstream
	prmeed = !hub pull-request --push -a sarpik  --base sarpik:master -depo --head sarpik:"$(git symbolic-ref --short HEAD)" # targets origin  (your repo)

Proposed solution

I can think of maybe having something like a "local" option, which makes any command operate on the local repo (the repository you forked, not the original one), something like -l, --local,

or allow selecting the remote, just like hub allows you to, say --head that's --repo, but also provide some sugar to make it easier - for example:

a) if the --repo option is not provided - do whatever you do currently;
a) if it is provided with a specified head - use that;
a) could we possibly allow a less verbose format for --repo?
something like only providing the OWNER and using the current repo's name as the REPO automatically?
a) (!) if the --repo option is provided without anything specified - default to the local repo (if that's even possible).

Additional context

This would allow simplier alias set-ups, such as the alias examples shown in #294 & here - above.

Thanks & best of luck with the cli!


Edit:

I really like the idea of @bbutkovic @ #251 (comment):

Perhaps we could add some sort of a flag (--self) to actually open a PR on the current repo instead of fork if someone does end up needing this.

but allow this not only for PRs, but also for issue & any other commands that can either operate.

This would make things way simplier, because you could share your aliases with others without either them having replace the user & repo.

So the request is to either improve the --repo option, or add a new option - something like --self.


P.S.

If https://github.com/github/hub still matters, could we also get a similar feature there for the --head option?

The alias example shown above could really use it for good,
but I assume that if the gh cli will provide this functionality,
it's probably unnecessary.

Activity

  1. vilmibm commented on Feb 7, 2020

    @vilmibm
    Contributor

    bunch of good ideas in here, thank you!

  2. jasonkarns commented on Feb 24, 2020

    @jasonkarns

    It would be great if the owner/repo information were stored via git-configuration. That would allow one to set the "override" within the repo itself and gh could infer the correct repo without requiring a --repo flag on every command invocation.

  3. phil-blain commented on Jul 16, 2020

    @phil-blain

    a) could we possibly allow a less verbose format for --repo?
    something like only providing the OWNER and using the current repo's name as the REPO automatically?

    yes, and also ideally respect the name of any configured remotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions