Cleaning Up Local and Remote Branches - acquaman/acquaman GitHub Wiki

When a branch has been merged into the required master branch and deployed on the beamline for a sufficient length of time to be confident that the issue has been resolved, it will be necessary to clean up the list of local and remote branches. Deleting local and remote branches prevents the repository from becoming unnecessarily cluttered.

Deleting a Local Branch

Note: In order to delete a local branch all changes must be committed and properly merged, or performing the delete will fail. In this case a delete can be forced (see Forcing a Delete of an Unmerged Local Branch)

  • Make sure you're not on the branch you wish to delete by checking out your master: git checkout Master where Master is your master branch.
  • Delete the issue branch: git branch -d Issue### where Issue### is the branch you wish to delete

Forcing a Delete of an Unmerged Local Branch

Note: Obviously you should be pretty certain at this stage that you actually wish to delete this branch, and that you aren't bothered about losing the changes contained within it.

  • Make sure you're not on the branch you wish to delete by checking out your master: git checkout Master where Master is your master branch.
  • Delete the issue branch: git branch -D Issue### where Issue### is the branch you wish to delete

Deleting a Remote Branch

Note: Once again you have to be pretty careful with this one. Once a branch has been deleted from the local and remote repositories there won't be any way of getting it back.

  • Delete the remote branch: git push origin :Issue### where Issue### is the name of the remote branch you wish to delete.