gitext-rs / git-stack

Stacked branch management for Git
Apache License 2.0
505 stars 19 forks source link

Add a way to push all branches that have a remote branch #191

Open Gelio opened 2 years ago

Gelio commented 2 years ago

Hey! I'm opening an issue to capture the functionality discussed in https://github.com/epage/git-stack/discussions/189#discussioncomment-2276150 that would allow git stack --push to push all branches that already have a corresponding remote branch, even if they are not considered ready.

That would help when working with stacked PRs, since I would be able to push all branches on my branches stack with a single command. At the moment, only the first branch from the stack is pushed, since that is the only one that is considered ready. Other branches are not ready, because their parent branch (the previous branch on the stack) is not merged into the protected branch yet.

To make this work, we would probably need another configuration option/flag. If enabled, git stack --push would override the existing ready check and instead treat a branch as ready if:

  1. it has no WIP commits (probably)
  2. there is a remote branch with the same name

Question to answer: for the 2nd condition, what if the local branch is named differently than the remote tracking branch? This could happen if the user manually set the remote tracking branch. git stack --push would push to the branch under the same name anyway, ignoring the remote-tracking branch, so it seems like a tangential issue that can be handled separately. A quick note is that I believe we could use the @{push} revision to push to the remote branch according to the user's push.default and other config options.

pietvanzoen commented 1 year ago

+1 this request.

I don't like leaving a lot of work locally on my machine without a remote backup so I tend to git push --force-with-lease all my stacked branches while they're in progress.

arxanas commented 1 year ago

By chance, I recently added this functionality to git-branchless in https://github.com/arxanas/git-branchless/pull/541. It introduces a git submit command which force-pushes all branches which have a remote in the current stack (or selected commits), and with --create, will push any local branches which don't have remote branches.

There's still some UI work that needs to be done for deciding when to create branches, but I think git-stack users weren't expecting the command to create branches for them anyways.

epage commented 1 year ago

From the original discussion

https://github.com/epage/git-stack/pull/190 will help. I want to have the "push whats already pushed" but there will be a little more work to make sure I get the logic right. Mind opening an issue about that so we can make sure we continue to track it?

Wish I had written down what this was

I don't like leaving a lot of work locally on my machine without a remote backup so I tend to git push --force-with-lease all my stacked branches while they're in progress.

Note that, at it stands, this issue would only help once you've pushed and not for new branches. You'd still need to manually push.

https://github.com/epage/git-stack/pull/190 will help. I want to have the "push whats already pushed" but there will be a little more work to make sure I get the logic right. Mind opening an issue about that so we can make sure we continue to track it?

Wish I knew what I was referring to here.

By chance, I recently added this functionality to git-branchless in https://github.com/arxanas/git-branchless/pull/541. It introduces a git submit command which force-pushes all branches which have a remote in the current stack (or selected commits), and with --create, will push any local branches which don't have remote branches.

It would be a help for me in following what you all are doing and seeing how we can cross-pollinate ideas if more details were put in the PR.

arxanas commented 1 year ago

@epage posted discussion here https://github.com/arxanas/git-branchless/discussions/564

allista commented 10 months ago

+1 to this request

A pity it is suspended for more than a year now :disappointed:

Alas, I'm not a rust guy to help quickly.