Skip to content
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

Not entirely clear what to do when an intermediate chain link PR merges in #12

Open
delfu opened this issue Mar 10, 2021 · 8 comments
Open

Comments

@delfu
Copy link

delfu commented Mar 10, 2021

Say i have a chain master -> a -> b -> c and a is now merged into master (with squashing). Do we need to create a new chain? how to remove a from the chain? is there a way to remove the squashed commits from a automatically?

@nathggns
Copy link

I have the same issue – although without squashing. I currently have a command that deletes local branches when they get merged remotely, and I'm love a way to remove the branch from the chain easily.

Equally there's no obvious way to manually delete a whole chain if you mess it up somehow?

@delfu
Copy link
Author

delfu commented Mar 10, 2021

once the intermediate PR closes and you delete the local branch, does the chain still work?

@lmbollen
Copy link

Bumping this issue because I'm running into the same issue.
I had a chain of which the base is now merged into master, and I'm not sure if I can still use the chain or what I should do.

@KyleFin
Copy link
Contributor

KyleFin commented Sep 21, 2022

I think Prune fixes this, right?

@simonc
Copy link

simonc commented Aug 29, 2023

If it can help, here's my own process:

  1. Merge the PR on Github with branch auto-delete enabled
  2. Run the following commands
# The two commands below are aliased as `pp` for me
git pull
# This will prune the deleted branch for the origin remote and also delete their local counterparts
git remote prune origin | rg --pcre2 -o '(?<=\[pruned\] origin/).+' | xargs git branch -D

# Finally, the same chain setup command but with `a` skipped
git chain setup -c chain-name main b c

For pruning deleted branches I use ripgrep but you can also look into git-removed-branches, I just haven't tested it yet.

Hope this helps 😊

@ndench
Copy link

ndench commented Nov 30, 2023

This doesn't seem to work for me. The chain still contains the commits from branch a, so git chain rebase tries to rebase the entire chain onto main when it should be only rebasing from branch b.

@KyleFin
Copy link
Contributor

KyleFin commented Dec 5, 2023

no obvious way to manually delete a whole chain if you mess it up

@nathggns, There is now a git chain teardown command!

Mine sometimes gets messed up with remote squashes etc (as described by OP). Then I:

  • Do an interactive rebase to rebase b on main, excluding commits from a
    • Maybe there's a better way, but I usually end up doing an interactive rebase for b, c, etc.
  • git chain teardown -c myChain
  • git chain setup -c myChain main b c

But in the happy case where things work without squashing and you don't need to teardown/setup the whole chain from scratch, this is my work flow:

  • main -> a -> b -> c
  • Merge a into main on GitLab
  • git pull && git chain rebase (a and main are now at the same commit)
  • git chain prune -d (remove a from chain and delete local branch a)

@nathggns
Copy link

nathggns commented Dec 5, 2023

@nathggns, There is now a git chain teardown command!

That's fantastic. Thank you!

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

No branches or pull requests

6 participants