![]() ![]() ![]() We strongly recommend using task branches - short-lived branches where an individual developer works to complete a task. ![]() We optimized all our tools to be ready to deal with limitless numbers of branches. Not that they are mistaken or anything - they simply follow a different way of working. Open two of the most popular Git GUIs out there with as few as 1k branches and watch them crash. In Git, you need to delete branches because GUIs are not ready to deal with them. We have customers with way more than that. It is an underlying different viewpoint.Ģ) Most Git GUIs crash with lots of branches. We like to tell a story on each checkin, to help reviewers speed up their work, instead of grouping tons of changes together into a single changeset ready to be merged. Yes, that's why they like to squash branches, delete them and so on, but we have a radically different vision about all that. I really like to show the blame of a file, spot a given line, and immediately see which was the task branch in which it was created. We see Plastic acting like a wise librarian - preserving history for the sake of not repeating mistakes and creating lots of knowledge from previous work. This means that in Git is very easy to lose where a commit came from, while in Plastic, changesets always belong to a single branch and their history is preserved. In the branches view, it is possible to customize the query to show only the branches with changes in the last N days: In Plastic, there are several ways to filter branches to focus on the most recent history. Plastic GUIs don't struggle with thousands of branches… unlike Git GUIs In the following topics, I'm going to explain the whys in detail. We also preserve branches because… Plastic doesn't break with dozens of thousands of branches, not the core, nor the GUIs… unlike Git. We preserve history because it is great to do a diff, or a blame of a file, and find the branch where it was done, and the direct link to the associated task with all the extra info it contains. So, if you are new to Plastic, and found this blogpost when trying to find how to "delete branches", I'm sorry to say the answer is NO, we don't delete… but for a reason :-) The reason is because these users have a very Git-centric view of version control. If you are a hard-core Plastic user you might think why someone would want to remove a branch with changesets on it. They want to get rid of them after the branch is merged because they are worried about polluting the repo with countless branches. I wanted to create something that is more robust that the solutions I found online that involve parsing porcelain commands like git branch -vv or git branch -merged.Sometimes users ask if it is possible to delete branches in Plastic. If you want a different deletion policy you might be able to modify the script to fit your needs.īy the way, I'd appreciate if any git wizards could have a look at what the script is doing. To be on the safe side, this script only deletes a branch if it has already been merged to master and if the branch was set to track the upstream branch (with push -u or branch -u). If thenĮcho "The current branch will be deleted because it has already been merged."Įcho "You are now in detached head mode." ![]() If git merge-base -is-ancestor "$branch" origin/HEAD then Delete the local branch if it has been merged If upstream=$(git rev-parse -abbrev-ref 2>/dev/null) then If git config -get "branch.$branch.remote" > /dev/null then # Is this branch set to track an upstream branch? Git for-each-ref refs/heads -format="%(refname:short)" | while read -r branch do Git remote set-head origin -auto || exit 1 # origin repo doesn't use "master" as the default branch. # We can use origin/HEAD instead of origin/master in case the # Create origin/HEAD if it does not already exist. # Delete the remote branches, and ensure that we are inside a git repo. What I ended up doing was to create a bash script to automate the process of deleting them when the corresponding Github pull request has been merged. However, that tick doesn't work for branches that you are working on and adding commits to, because in those cases you need to have a local branch. For example, if you just want to have a look at a branch that someone else created you can use git switch -detach origin/foo instead of git switch foo, which avoids creating a local foo branch. One thing that helps is to avoid creating local branches if you can. I think you need to separately call git branch -d for each of them. However, as far as I know there isn't an easy way to also delete the local branches at the same time. You can delete the remote branches (origin/xxx, etc) using git remote prune origin or git fetch -prune. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |