Science and technology

Delete the native reference to a distant department in Git

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

Example output:

* grasp

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

Example output:

Pruning origin
* [would prune] origin/test-branch

Next, prune the native reference to the distant department:

$ git distant prune origin

Example output:

Pruning origin
* [pruned] origin/test-branch

That’s it!

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.

Click to comment

Leave a Reply

Your email address will not be published.

Most Popular features the latest multimedia technologies, from live video streaming to audio packages to searchable archives of news features and background information. The site is updated continuously throughout the day.

Copyright © 2017 Breaking Express, Green Media Corporation

To Top