-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I re-enable force pushing, or should I change my workflow? #3437
Comments
Sorry for breaking your workflow. This is very interesting, I hadn't expected people to work this way. You seem to find it more important to see the divergence from I'm a little unsure what to do here. While I see how your workflow is convenient, it still feels very weird to me, and I'm not sure how hard we should try to support it. Happy to discuss this more though. That said, I have always missed an easy way to see the divergence of my branch from |
Hi @stefanhaller, many thanks for reply and sorry for my delayed response 🙂 It’s exactly as you describe – I work mostly in a team where everyone is pushing their work into their branches on I absolutely understand that it’s a nonstandard workflow and I plan to continue use lazygit even without support for it, it’s a great tool whose benefits for me definitely outweigh the current slight inconvenience 🙂 That said, regarding your last paragraph, as a former user of Magit, I find it’s way of dealing with this really quite convenient. When you check out Perhaps something along those lines might be adapted to work with lazygit and I’d be happy to discuss this further. If there eventually is an idea that you guys might want to include, I’ll be happy to take a shot at implementing it 🙂 |
I work on a repo that fast-forward only merge is enabled. So I need to rebase and force-push the branch before merging. Force push is used very frequently in my workflow. Can I override the |
@linsui Sorry for the late response. Is your setup similar to Jakub's, where you pull from a different branch than you push to? If not, you'll have to explain more what the problem is, because I don't see how being restricted to fast-forward-only merges is related. @jakubledl I'm curious what your current work-around is. Did you change your workflow, or are you using a custom command to force-push, or something else? (I hope you didn't stop using lazygit because of this. 😄) I made a quick proof-of-concept draft PR (#3528) with a change that should support your workflow correctly, so pressing shift-P should prompt you to force-push in the appropriate cases. Would be cool if you could try it out. |
You are correct. I didn't notice that |
Did you have the problem with a stale remote tracking branch that was mentioned in the stackoverflow answers, or was it some other reason why it didn't work? Usually, |
I thought my push sometimes fails due to the stale remote tracking branch issue. I usually working with the same local branch and the remote branch is deleted automatically when my MR is merged. So lazygit can't fetch the remote branch. I guess so... |
I see. In that case I recommend to do All of that seems unrelated to this issue though. |
Good idea, thanks for your help! Yep, I thought this is an unrelated issue. |
@stefanhaller So currently, I don't really have a workaround 🙂 I have the local feature branch's upstream set to the remote feature branch and I use the local Thanks for the draft PR, I'll be happy to give it a try in the next few days! I'll also look into custom commands, since that's a topic I haven't really explored yet. |
@jakubledl you don't have to checkout a branch to pull it, you can just fast forward it with |
@mark2185 Thanks for the suggestion, that's definitely quicker! On the other hand, if I checkout |
I like to do Jakub, I'm also interested in your thoughts on #3536, I personally think this will help a lot, and I intend to start working on it very soon. |
Hi @stefanhaller, I gave the Will look into #3536, thanks! |
I think this can always happen, no matter which workflow, when your clone's remote branches are not up to date. Lazygit makes the decision whether to ask for force-push only based on the divergence of feature vs. the local copy of the remote tracking branch; so if that one is out of date because something has been pushed to the other side since you last fetched, you won't get the force-push prompt and it will error out instead. Fetching helps in this case. The fact that it worked after you quit and restarted lazygit supports this theory, since fetching is the first thing lazygit does after starting. Actually, this scenario is the very reason why I did #3387, since without fetching you didn't have a chance to check what you are overwriting by force-pushing. |
- **PR Description** Some people push to a different branch (or even remote) than they pull from. One example is described in #3437. Our logic of when to request a force push is not appropriate for these workflows: we check the configured upstream branch for divergence, but that's the one you pull from. We should instead check the push-to branch for divergence. Fixes #3437.
When developing on a branch
feature-asdf
, I'm used to having the upstream of the branch set toorigin/main
and havepush.default
set tocurrent
. This means that whenever someone else merges something toorigin/main
, I immediately see it as↑m↓n
, I can pull and rebase ontoorigin/main
with a simplep
and I could push the rebased branch with justP
andEnter
to confirm the force push.After upgrading to
0.41.0
, #3387 of course broke this workflow, since now it's impossible to force push the branch after the rebase. Is there a way I can get the old behavior back, or should I perhaps do something else entirely? I switched to lazygit from Magit when I stopped using Emacs a few months ago, so it's possible I'm just trying to recreate something that I'm used to and that lazygit has a different/better way to do.The text was updated successfully, but these errors were encountered: