Commit graph

55 commits

Author SHA1 Message Date
Kynan Ware
6045a593a3
Reword --no-upstream help doc 2026-03-03 15:51:27 -07:00
4RH1T3CT0R7
fa95f3a21b Add --no-upstream flag to gh repo clone
When cloning a forked repository, `gh repo clone` automatically adds the
parent repo as an `upstream` remote and sets it as the default repository.
This can be problematic when the user lacks access to the parent repo,
the upstream fetch is expensive for large repos, or the user simply
doesn't want the upstream remote.

Add a `--no-upstream` flag that skips adding the upstream remote when
cloning a fork. When used, origin (the fork) is set as the default
repository instead. The flag is mutually exclusive with
`--upstream-remote-name`. For non-fork repos the flag is a harmless
no-op.

Closes #8274
2026-02-14 20:31:02 +03:00
William Martin
07e0ff7127 Fix repo fork to use remote protocol if none configured 2024-05-10 10:48:36 +02:00
William Martin
1d38230675
Move config interfaces into gh package (#9060) 2024-05-10 10:39:36 +02:00
William Martin
825beef723 Document repo clone protocol behaviour 2024-04-30 08:22:49 +02:00
Babak K. Shandiz
7d432bcd3a
Support long URLs in gh repo clone (#9008)
Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
2024-04-29 14:42:18 +02:00
Yukai Chou
07a87ca8a4 Wrap special values and placeholders like - and $1 2023-11-23 07:09:29 +08:00
Sam Coe
7924878315
Fix git protocol and refactor Config interface (#8246) 2023-10-27 15:42:05 +02:00
William Martin
6dc04bb1e2 Remove GetOrDefault uses in favour of GitProtocol 2023-10-19 12:57:19 +02:00
Keith Bailey
363dacbbed
Set default repository for repo clone and repo fork (#7768) 2023-10-11 13:41:00 +00:00
Sam Coe
fac497108b
Set upstream remote to track all branches after initial fetch (#7542) 2023-06-12 09:23:56 +09:00
Sam Coe
c9a2d85793
Cleanup config.AuthToken and config.DefaultHost methods (#7049) 2023-02-28 00:24:45 +00:00
Mislav Marohnić
14eb873b9e
Avoid implicitly fetching when adding a new git remote (#6990) 2023-02-07 21:22:02 +00:00
Sam Coe
98ab1f2587
Authenticate network git commands (#6541) 2022-11-15 13:14:37 +02:00
Sam Coe
4294ee14a1
revert revert 57fbe4f317 (#6474) 2022-10-20 12:17:20 +00:00
Sam Coe
2cefb9fa59
Fix pr create regression (#6472)
* Revert "Refactor to use new git client (#6447)"

This reverts commit 57fbe4f317.

* Fix pr create regression
2022-10-20 12:46:23 +03:00
Sam Coe
57fbe4f317
Refactor to use new git client (#6447) 2022-10-19 21:11:36 +03:00
Sam Coe
cacff4ad6d
Use go-gh config package (#5771) 2022-06-23 11:50:04 +00:00
Ahmed Adan
31bee2e639
Add --upstream-remote-name flag to gh replo clone (#5619) 2022-05-24 13:12:01 +02:00
Mislav Marohnić
2139e763fb Write Cobra deprecation messages to stderr
We used to do the equivalent of `rootCmd.SetOut(os.Stdout)` because we
thought that Cobra's "Out" stream represents standard output. However,
upon closer inspection it turns out that this is Cobra's stream for
usage errors and deprecation warnings, and those we want written to
stderr as well. It is not clear to me why Cobra maintains a distinction
between "Out" and "Err" streams since both seem to go to sdterr by
default.

This change also ceases our usage of `command.Print()` functions in
favor of explicitly writing to `IOStreams.Out/ErrOut`.
2022-05-23 20:23:42 +02:00
Dan Halbert
51d18d95f1
repo clone: document the upstream remote (#5466)
Co-authored-by: Mislav Marohnić <mislav@github.com>
2022-05-10 18:12:59 +02:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
nate smith
562f1b3d0d add GetOrDefault functionality to config 2022-01-11 14:56:58 -06:00
Alan Donovan
f4491c7a80 Add FlagErrorf; encapsulate FlagError.error 2021-10-21 11:40:20 -04:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Sam
9ec1e21d4c
Default to GHES host if only GHES is authenticated (#3286) 2021-03-30 16:51:00 +02:00
Mislav Marohnić
06cf2c9f81 Merge remote-tracking branch 'origin' into cmd-stub-new 2021-01-22 16:31:29 +01:00
Nate Smith
29805a4003
Merge pull request #2588 from cdce8p/gh-clone-fetch
Only fetch default branch when adding upstream remote
2021-01-21 12:57:10 -08:00
vilmibm
b906826a68 i like trunk 2021-01-21 12:56:53 -08:00
vilmibm
dcedd32249 use newer command stubbing in tests 2021-01-21 12:32:40 -08:00
Mislav Marohnić
75ebb863e3 Use testify assertions for error matching 2021-01-19 13:59:37 +01:00
Mislav Marohnić
584b33e79c Migrate to new cmd stubber in repo clone tests 2021-01-18 22:42:13 +01:00
Mislav Marohnić
39a0a8c57c Improve clone wiki test 2020-12-15 17:45:13 +01:00
gunadhya
fd57835bb9 Fix repo clone wiki 2020-12-15 17:45:03 +01:00
cdce8p
f536901bc1 Only fetch DefaultBranchRef when adding upstream remote during gh repo clone 2020-12-09 20:15:21 +01:00
boonhong
57ec879aea Fix typos 2020-11-12 22:32:36 +08:00
Alisson Santos
cf617e88f4 Extract repeated code to util function 2020-11-03 22:05:04 +01:00
Mislav Marohnić
fc969281cf Better tests for clone argument parsing 2020-10-29 16:52:50 +01:00
Eric Hagman
af1d8a60e0 Print friendly error when "gh repo clone" is missing required argument 2020-10-21 23:23:39 -04:00
Jonathan Lloyd
8f44aee76a Load repo and parent in single query 2020-10-13 20:41:16 +01:00
Jonathan Lloyd
a5ec03d000 Improve test args 2020-10-12 23:57:47 +01:00
Jonathan Lloyd
487b62d3b9 Clone repos using canonical username/repo name capitalization
GitHub user/repo names are case insentitive. This can cause issues when dealing with
repos programmatically using systems that aren't aware of this (e.g. go packages).

This commit updates the cloning logic of the CLI to query the API for the canonical
capitalization and uses that for the clone operation.

Fixes: #1845
2020-10-12 23:39:18 +01:00
Mislav Marohnić
c095a4bead Allow explicitly specifying the hostname for gh operations
Accept the "HOST/OWNER/REPO" syntax or passing a full URL for both the
`--repo` flag and the GH_REPO environment variable and allow setting
GH_HOST environment variable to override just the hostname for
operations that assume "github.com" by default.

Examples:

    $ gh repo clone example.org/owner/repo
    $ GH_HOST=example.org gh repo clone repo

    $ GH_HOST=example.org gh api user
    $ GH_HOST=example.org gh gist create myfile.txt

    $ gh issue list -R example.org/owner/repo
    $ gh issue list -R https://example.org/owner/repo.git
    $ GH_REPO=example.org/owner/repo gh issue list
2020-08-12 16:16:34 +02:00
Mislav Marohnić
00bdedb418 💅 Tweak wording 2020-08-11 17:06:36 +02:00
Mislav Marohnić
d876cf15b0 Merge remote-tracking branch 'origin' into issue-1456__clone-flag-help 2020-08-11 16:57:24 +02:00
Mislav Marohnić
a73584db72 Merge remote-tracking branch 'origin' into pr-commands-isolate 2020-08-04 15:01:30 +02:00
Shi Han NG
d24f33b679
Add Test_RepoClone_flagError 2020-08-01 19:23:28 +09:00
Shi Han NG
6e844fef87
Mention git clone flags in gh repo clone usage 2020-08-01 19:09:29 +09:00
Shi Han NG
ca8d032824
Add custom error for gh repo clone 2020-08-01 19:07:51 +09:00
Mislav Marohnić
ffe08995bb Add notes about GHE support for git_protocol 2020-07-29 22:50:53 +02:00