git fetch --prune

Fetches new branches and removes deleted branches

This command fetches new branches and updates the remote-tracking branches for all branches in the remote repository. It also removes any remote-tracking branches that no longer exist on the remote repository. This is useful when you want to keep your local repository in sync with the remote repository, ensuring that you have the latest branch updates and removing any branches that have been deleted on the remote repository.

Potential variations:

  • You can use the -p short flag instead of --prune to achieve the same result.
  • You can use git fetch --all --prune or git fetch --all -p to fetch updates from all remote repositories and prune deleted branches from all of them.
Related