After you merge a GitLab or GitHub pull request, you often delete the subject department within the distant repository to take care of repository hygiene. However, this motion deletes the subject department solely within the distant repository. Your native Git repository additionally advantages from routine cleanup.
To synchronize the data in your native repository with the distant repository, you may execute the
git prune command to delete the native reference to a distant department in your native repository.
Follow these three easy steps:
1. Checkout the central department of your repository (reminiscent of fundamental or grasp)
$ git checkout <central_branch_name>
2. List all of the distant and native branches
$ git department -a
In this instance,
test-branch is the title of the subject department that you simply deleted within the distant repository.
3. Delete the native reference to the distant department
First, record all of the branches which you could delete or prune in your native repository:
$ git distant prune origin --dry-run
* [would prune] origin/test-branch
Next, prune the native reference to the distant department:
$ git distant prune origin
* [pruned] origin/test-branch
Maintaining your Git repository
Keeping your Git repository tidy could not appear pressing at first, however the extra a repository grows, the extra essential it turns into to prune pointless information. Don’t sluggish your self down by forcing your self to sift via information you now not want.
Regularly deleting native references to distant branches is an efficient apply for sustaining a usable Git repository.