Skip to content

Owner doesn't change if cloned from fork #8440

Closed

Description

@littleblack111

Describe the bug

was forking my friend's repository and after forking it directly with gh repo fork and cloned(using option from the same command) it.
After that I relises it have a stupid name and i tried to change with gh repo rename which it says it tried to change name with my friend's name and it's 404

gh version 2.40.0 (2023-12-07)

Steps to reproduce the behavior

  1. gh repo fork someone's fork and clone it when asked so
  2. gh repo rename in that cloned directory
  3. gh repo rename
  4. it will output HTTP 404: Not Found (https://api.github.com/repos//)

Expected vs actual behavior

It rename for me as the owner instead of the original owner before the fork

Logs

HTTP 404: Not Found (https://api.github.com/repos//)

Activity

  1. added
    bug
    on Dec 9, 2023
  2. added
    needs-triage
    on Dec 9, 2023
  3. littleblack111 commented on Dec 9, 2023

    @littleblack111
    Author

    EDIT:
    I would expect it to rename from origin not upstream, if i change .git/config and copy origin url to upstream and it will all be fine

  4. williammartin commented on Dec 9, 2023

    @williammartin
    Member

    I expect that this occurs because repo set-default is automated to point to upstream on clone of a fork. This probably isn't the right behaviour if so but I need to think about it.

    In the meantime I'd be interested what happens if you gh repo set-default first to origin and then try the rename.

  5. added
    more-info-needed
    and removed
    needs-triage
    on Jan 11, 2024
  6. williammartin commented on Jan 16, 2024

    @williammartin
    Member

    @littleblack111 have you had a chance to check:

    In the meantime I'd be interested what happens if you gh repo set-default first to origin and then try the rename.

    Thanks.

  7. littleblack111 commented on Jan 16, 2024

    @littleblack111
    Author

    Sorry for later reply, and yes, it works after repo set-default when forked

  8. added
    priority-3
    and removed
    more-info-needed
    on Jan 16, 2024
  9. williammartin commented on Jan 16, 2024

    @williammartin
    Member

    Yeh that makes sense to me. I think gh repo rename should not be trying to use the default repo but the current repo. I expect it will be low priority for us to fix. Thank you for reporting!

  10. added
    gh-repo
    on Jan 16, 2024
  11. added
    help wanted
    on Feb 14, 2024
  12. max-ishere commented on Feb 14, 2024

    @max-ishere

    #8659 (comment)

    @max-ishere can you write a single comment providing full context into the state of the remote and locally cloned repos. I don't have the full picture in my head of the workflow you are describing. If #8440 is more appropriate then please write it there, thank you.

    I did the same thing as OP, forked a project, cloned it locally like this:

    gh repo fork
    Forking ...
    Do you want to clone the repo? Yes
    

    (I dont remember the exact prompt)

    And I expected that since i asked for a fork and it cloned it, then the default repo would be origin and not upstream.

  13. williammartin commented on Feb 14, 2024

    @williammartin
    Member

    To give a counter example, if you gh repo clone upstream, gh repo fork, do some work, gh pr create, you would expect the PR to be created against the upstream, not your fork.

    Like I described in #8440 (comment), perhaps repo unarchive should be using the current repo rather than the default.

  14. max-ishere commented on Feb 15, 2024

    @max-ishere

    Yeah of course. If I do

    gh repo clone upstream
    

    Then what I expect gh to do is something like this:

    git clone (upstream)
    
    cd upstream
    
    git remote get-url origin 
    [email protected]:upstream.git
    

    But when it asks this:

    gh repo fork upstream
    ? Would you like to clone the fork? Yes
    

    I assume it does:

    git clone fork
    
    git remote get-url origin
    [email protected]:fork.git
    
    git remote get-url upstream
    [email protected]:upstream.git
    
    # default is set to origin
  15. max-ishere commented on Feb 15, 2024

    @max-ishere

    Like I described in #8440 (comment), perhaps repo unarchive should be using the current repo rather than the default.

    No, the default should be whatever the prompt suggests it is going to be... This is just going to be more confusing if you have a default and then unarchive has its own default that you need to set somehow else?

  16. williammartin commented on Feb 15, 2024

    @williammartin
    Member

    Yeah of course. If I do gh repo clone upstream

    That was only the first part of what I said. It was followed by forking the upstream.

    It would be quite confusing if the following commands behaved differently with regards the default:

    • gh repo clone fork
    • gh repo clone upstream && cd upstream && gh repo fork
    • gh repo fork upstream > yes clone the fork

    Since by far the most common use case is that users are forking in order to contribute back to the upstream, we choose the upstream as the default.

    This is just going to be more confusing if you have a default and then unarchive has its own default that you need to set somehow else?

    I'm not suggesting there's another default that you need to set, I'm suggesting that perhaps there are some set of commands which you are more likely to want to work against the fork than the upstream and we should think about whether there's a reasonable UX for that.

  17. williammartin commented on Feb 15, 2024

    @williammartin
    Member

    Also, now that I think about it, any change here would need to be backwards compatible so more likely than not we won't be able to make a simple change.

  18. max-ishere commented on Feb 18, 2024

    @max-ishere

    I understand that... But also... The current behavior feels like a bug. So I'd be fine if it would be fixed rather than acknowledged as the correct behavior.

    I actually didn't test what would happen if I clone the fork, I wonder if that's gonna have default repo as upstream too. Can't test for now.

  19. max-ishere commented on Feb 18, 2024

    @max-ishere

    I didn't see the above comment on mobile. So if you don't change the behavior at least change the prompt to clone to say what it actually does. Which is cloning upstream.

  20. max-ishere commented on Feb 18, 2024

    @max-ishere

    ...some set of commands which you are more likely to want to work against the fork than the upstream

    Exactly what I mean by multiple defaults. This reminds me of the JS string and number addition where you coerce the types implicitly and get unexpected behavior. I expected that when I do an operation it's gonna happen against the default unless I specify what repo I want.

  21. max-ishere commented on Feb 18, 2024

    @max-ishere

    That was only the first part of what I said. It was followed by forking the upstream.

    Regardless it should not change the default repo or if it does ask about it.

  22. max-ishere commented on Feb 18, 2024

    @max-ishere

    gh repo clone fork
    gh repo clone upstream && cd upstream > && gh repo fork
    gh repo fork upstream > yes clone the fork

    All these should set default to whatever they are cloning if you fork, you already cloned upstream it was the default already.

  23. max-ishere commented on Feb 18, 2024

    @max-ishere

    Sorry for the magnitude of comments I literally just opened the mobile app and kinda forgot how to use GitHub and also am a little sick rn so I'm having some brain fog from that too.

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

    buggh-repohelp wantedpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions