We can run the git branch to check all the branches that remain. The code above excludes the master and any branches that contain importance in its name. Note that you might also need the -f flag if youre. This is a dangerous script but you could always check out a given branch from a remote. Using the -d flag, you tell git branch which item you want to delete. The shell command above deletes every branch in your local checkout except for master branch. Now, if we run git branch command, we will see that. ![]() Note: The grep sequence contains the branches we do not want to delete. When you're ready to do some real cleanup on a repository, throw this at it: git branch grep -v 'master' sed 's/ //' sed 's//git branch -d /' bash. To delete a local branch, we can use the git branch -d command. Git branch -merged | grep -i -v -E "master|important"| xargs git branch -d Delete all merged branches: To delete all the Git branches that have been merged, run the code below:.List all the branches that have been merged: The first step to delete all Git branches which have been merged is to list the branches.Note: Git Bash is an application for Microsoft Windows environments that provides an emulation layer for a Git command line experience.īelow are the steps to delete Git branches that have been merged: This command will list all the branches in your local Git repository (excluding the master branch), and then use the xargs command to pass the branch. You can do this in your command prompt, terminal (for mac users), or Git bash. Implementationĭeleting branches that have been merged is an easy task. Let’s discuss the steps required to delete branches that have been merged. Maybe you've got another branch called staging that you wish to preserve as well. Deleting branches that have been merged into the main is inevitable. git branch: list all local branches grep -v 'master': filter out the word 'master' from the list xargs git branch -D: delete all branches in the list Keeping more than 1 branch. Building a program can be a very tiring and time-consuming task.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |