Skip to content

Conversation

karolzwolak
Copy link

@karolzwolak karolzwolak commented Aug 17, 2025

PR Description

The command allows you to quickly add a new 'fork' remote with
replaced owner in the origin URL of the selected remote.

For example:
given url: https://github.com/jesseduffield/lazygit.git
and username: karolzwolak
adds a new remote with url: https://github.com/karolzwolak/lazygit.git

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc
clip.mp4

The command allows you to quickly add a new 'fork' remote with
replaced owner in the origin URL of the selected remote.

For example:
given url: https://github.com/jesseduffield/lazygit.git
and username: karolzwolak
adds a new remote with url: https://github.com/karolzwolak/lazygit.git
@stefanhaller
Copy link
Collaborator

Thanks for the PR, and sorry for the long delay in looking at it.

This is a useful feature, I need it myself frequently. Before I review in detail, a few general thoughts:

  • it would be even more useful if it could take a repo:branch specification and create the remote and check out the branch in one go. For example, for this very PR I would click the copy-to-clipboard icon here:
    Screenshot 2025-09-05 at 10 51 59, invoke the command, and paste. Any thoughts on this?
  • I didn't look at the code in detail yet, I only noticed from a cursory look that there are many lines of code related to parsing URIs. Is this really needed? Intuitively I would have thought that the implementation would consist of basically a single line of code doing a regex replace. I may well be missing something here, and I should probably look at the code in detail before asking questions like this.
  • How much of this is github specific? For me personally, github is the only hosting service that I have experience with, but lazygit supports a bunch of others (gitlab, azure devops, gitea, bitbucket). I wonder if we need to hook into hosting_service.go somehow to make it work for those, too.

@karolzwolak
Copy link
Author

Thanks for the PR, and sorry for the long delay in looking at it.

This is a useful feature, I need it myself frequently. Before I review in detail, a few general thoughts:

  • it would be even more useful if it could take a repo:branch specification and create the remote and check out the branch in one go. For example, for this very PR I would click the copy-to-clipboard icon here:
    Screenshot 2025-09-05 at 10 51 59, invoke the command, and paste. Any thoughts on this?

Yes, that's a great follow-up. It should be easy to do, too. I will implement it.

  • I didn't look at the code in detail yet, I only noticed from a cursory look that there are many lines of code related to parsing URIs. Is this really needed? Intuitively I would have thought that the implementation would consist of basically a single line of code doing a regex replace. I may well be missing something here, and I should probably look at the code in detail before asking questions like this.

Yeah, I might have gone overboard with the url parsing. I didn't know we had regex support. Regex would work well for ssh urls, but it's a bit more nuanced for http/https urls, but I'll try to simplify it.

  • How much of this is github specific? For me personally, github is the only hosting service that I have experience with, but lazygit supports a bunch of others (gitlab, azure devops, gitea, bitbucket). I wonder if we need to hook into hosting_service.go somehow to make it work for those, too.

I also don't have experience besides github, but I think most other hosting services follow the same owner/repo url pattern as github does, so it should work fine without any further modifications. I might be wrong on this, though.

I'm away from home for about 2 weeks, so I won't be active on this right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants