mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Tell gh What The Default Repo Is as a Git TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1667 TILs and counting..._
|
||||
_1668 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -415,6 +415,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
||||
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
|
||||
- [Transition A Branch From One Base To Another](git/transition-a-branch-from-one-base-to-another.md)
|
||||
- [Tell gh What The Default Repo Is](git/tell-gh-what-the-default-repo-is.md)
|
||||
- [Turn Off The Output Pager For One Command](git/turn-off-the-output-pager-for-one-command.md)
|
||||
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
|
||||
- [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md)
|
||||
|
||||
38
git/tell-gh-what-the-default-repo-is.md
Normal file
38
git/tell-gh-what-the-default-repo-is.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# Tell gh What The Default Repo Is
|
||||
|
||||
I recently forked [dkarter/dotfiles](https://github.com/dkarter/dotfiles) as a
|
||||
way of bootstrapping a robust dotfile config for a new machine that I could
|
||||
start making customizations to. I'm maintaining a `my-dotfiles` branch and keep
|
||||
things in sync with the original upstream repo.
|
||||
|
||||
When trying to go to *my* fork of the repo
|
||||
([jbranchaud/dotfiles](https://github.com/jbranchaud/dotfiles)) in the web with
|
||||
the `gh` CLI tool, I ran into a weird issue. It was instead opening up to
|
||||
`dkarter/dotfiles`.
|
||||
|
||||
`gh` was under the wrong impression which repo should be considered the default.
|
||||
To clarify things for `gh`, there is a command to set the default repo.
|
||||
|
||||
```bash
|
||||
$ gh repo set-default jbranchaud/dotfiles
|
||||
✓ Set jbranchaud/dotfiles as the default repository for the current directory
|
||||
```
|
||||
|
||||
Now when I run `gh repo view --web`, it opens the browser to my fork of the
|
||||
dotfiles.
|
||||
|
||||
But where does this setting live?
|
||||
|
||||
Opening this repo's `.git/config` file I can see a section for the `origin`
|
||||
remote that includes a new line for `gh-resolved`. This being set to `base`
|
||||
tells `gh` that this remote is the one to treat as the default repo.
|
||||
|
||||
```
|
||||
[remote "origin"]
|
||||
url = git@github.com:jbranchaud/dotfiles.git
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
gh-resolved = base
|
||||
|
||||
```
|
||||
|
||||
See `gh repo set-default --help` for more details.
|
||||
Reference in New Issue
Block a user