There will come a time when you optimize your workflow to ensure PR requests are as small as possible.
Each request can be minimal, so you end up w...
For further actions, you may consider blocking this person and/or reporting abuse
Very handy one-liners.
There should be a git command especially for this cases. Something like:
And the main branch is ignored by default, to not do something dangerous. Maybe also a hint if you delete a branch when you are checkout into it at the moment ...
Or some similar feature, with a good described documentation in one place π
Git is a goldmine for content creators.
So many common tasks don't have an intuitive solution, and the official documentation has a chicken and egg problem where you can search only what you already know how to do.
So lots of Google traffic.
There should really be a really good cleanup way actually.
Heck, even simply an automated way, merged branch -> get info back to delete it when it's not active anymore.
But at the very least indeed a option to make it easier and safe for people to do this.
When this starts happening at scale, this is probably an indication that we need to think at a higher level of abstraction than 'branches' and 'pull requests', or at least we need a tool that simplifies part of this workflow. Lately I am trying out Git Patch Stack for this. It creates a branch and a PR automatically from a single commit. At this level of abstraction it calls the combination of the branch and PR a 'patch'. You can create and layer multiple patches in a stack, the intention is that each patch gets sent as a PR to be reviewed. As patches are reviewed and merged, the patches above those ones are automatically rebased on top of the new branch head.
It takes a little setup thoughβthe tool by itself doesn't know how to create PRs, it relies on shell scripts called 'hooks' to do that. I am trying it out now but haven't yet made up my mind about whether it's the ultimate solution to the problem. I just think a solution above the level of branches is needed.
Thanks for that vision Yawar.
At what large scale are you working at, just interested to hear :)
Maybe this command is helpful to someone ;)
The command deletes all local branches without an origin attached
git fetch -p && for branch in $(git branch -vv | grep ': gone]' | awk '{print $1}'); do git branch -D $branch; done
Thanks for sharing Oli
Hi Chris, thanks for the post. Could you create series regarding git and git bash. I am struggling with git commands. Mostly when i've to work on already present repositeries. Could you make series how to use git and it's commands affectvily both for new repos and existed repos. Thanks in advance.
Hey,
I actually already did a whole series on Git, this one was kind of the aftermath.
You can find the full series here:
daily-dev-tips.com/tags/git/
Love these. I would suggest a mention of how to create an alias for these commands to make using them more intuitive(a challenge with git other comments point out). That is how I've set up similar commands for my shell.
example:
alias deleteLocalBranches="git branch | grep -v "main" | xargs git branch -D"
Yeah, wrote the alias on my todo list to refactor.
If you do have some time before me, feel free to modify it in my repo already.
github.com/rebelchris/daily-dev-ti...
Thanks β€οΈ! That's a useful command! I used to do git prune than going to delete the highlights branches in red by vscode π€!
With Oh My Zsh you can use the alias "gbda" :)
(git branch --no-color --merged | command grep -vE "^(+||\s($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d)
Oh dang! TIL π
Clone the repo again ;)
I used to do this π π€
Also good
Nice! Love it π
Actually if you want to can add it to my repo?
Would be great for other people too.
github.com/rebelchris/daily-dev-ti...
I literally went blank about how to do it earlier today (and then got distracted so never googled it). Thank you!
Glad it helped :)
Very useful.
Thanks Anamika