I started using Github CLI after its first release, that's a great tool. I've been working on a project, which needs to be in different places remotely, e.g. in two repositories. I can add another remote to push changes to it, but gh will only be able to control the initial one. As an example, gh pr status command in a repo which has two or more remotes, will only show data of origin remote. How can i switch between the remotes to see all actions like issues and pr's on each of them?
            Asked
            
        
        
            Active
            
        
            Viewed 454 times
        
    5
            
            
         
    
    
        Michael
        
- 657
- 4
- 29
1 Answers
2
            With gh 2.21.0 (Dec. 2022), you can use the new command gh repo set-default
This command sets the default remote repository to use when querying the GitHub API for the locally cloned repository.
ghuses the default repository for things like:
- viewing and creating pull requests
- viewing and creating issues
- viewing and creating releases
- working with Actions
- adding repository and environment secrets
This will avoid the interactive message Which should be the base repository?.
From now on (2.21.0+), gh commands in a repository with multiple remotes will now error out until a default has been chosen.
With gh v2.22.0 (Jan. 2023), gh repo set-default also works with remote bare repositories. (PR 6880)
With gh v2.30.0 (May 2023), you can use gh repo set-default --view without repo argument (PR 7441), in order to see the current default repository.
 
    
    
        VonC
        
- 1,262,500
- 529
- 4,410
- 5,250