What is git fetch --prune?
git fetch --prune
is a command that combines the functionality of git fetch
and git remote prune
. It fetches updates from the remote repository and removes any remote-tracking branches that no longer exist on the remote.
Syntax
git fetch --prune <remote-name>
Uses of git fetch --prune
- To update your local repository with the latest changes from the remote repository.
- Automatically removes stale remote-tracking branches that have been deleted from the remote.
Example
# Fetch updates from origin and prune stale remote-tracking branches
git fetch --prune origin
This command will fetch the latest changes from the origin
remote and remove any branches in your local repository that no longer exist on the remote.
Difference Between Git remote prune, Git prune and Git fetch –prune
Git is a version control system that helps developers manage and track changes in their codebase. Among its many commands, git remote prune
, git prune
, and git fetch --prune
are essential for maintaining a clean and organized repository. This article will explain the differences between these commands, their syntax, uses, and provide examples to illustrate their functionalities.