What's the cleanest way to update my fork when working with both origin and upstream remotes? #4651
-
Hi! This is my first time trying out Lazygit.
I’m working on a custom branch called study, and I regularly want to rebase it onto the latest upstream/master.
This was my regular way of keeping my fork (origin/master) in sync with the upstream repo, and then rebasing my feature branch study on top of it. I’m not sure if it’s really the cleanest way to update a fork honestly. Anyway, now I’m trying to achieve the same workflow in Lazygit, and the only approach that came to mind was:
Is there a better or cleaner way to accomplish this in Lazygit? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
This is a very good question, and one that doesn't have a good answer right now, I'm afraid. While the scenario you describe is a very common one for open source contributors, it is one that I haven't paid much attention to so far, because I am in the fortunate position that I have push access to all the repos that I regularly contribute to, so I only need one remote (origin), which makes everything much easier. Ok, let's see. There are two ways to set up the remotes in your clone, and they both have their pros and cons:
I suppose 1. is the more natural and intuitive setup for most people (although I'm not sure). It has the advantage that pushing branches to your fork is easier (it's a matter of pressing So with these two criteria, 1. is the clear winner. However, lazygit has this concept of main branches (master or main by default), which let you do several useful and convenient things. For example, it's easy to rebase a feature branch onto its base branch by typing However, all these features assume that these main branches are in your origin remote. This is only a useful assumption for setup 2., because with 1. you'd have to manually keep your fork's main branch up to date with upstream's to make use of these features, which is cumbersome and easy to forget. It seems to me that hard-coding In the meantime, the approach you describe above is reasonable, except that you can omit the steps
I would even consider deleting the master branch from your fork to prevent it from falling behind upstream's. So my recommended approach right now would be:
Then:
|
Beta Was this translation helpful? Give feedback.
-
I don’t want to start a new discussion over something so small, but is there a way to assign different pull and push URLs for the same remote? I’m asking because I want to disable pushes. So far, I’ve been using lazygit to create a remote called "upstream" with the correct URL for pull and then manually running this in the console:
Is there a way to automate this in lazygit? |
Beta Was this translation helpful? Give feedback.
This is a very good question, and one that doesn't have a good answer right now, I'm afraid.
While the scenario you describe is a very common one for open source contributors, it is one that I haven't paid much attention to so far, because I am in the fortunate position that I have push access to all the repos that I regularly contribute to, so I only need one remote (origin), which makes everything much easier.
Ok, let's see. There are two ways to set up the remotes in your clone, and they both have their pros and cons:
origin
is your fork, andupstream
is the upstream repoorigin
is the upstream repo, andmyfork
(or whatever name you choose) is your fork.I suppose 1. is the more natu…