If someone deleted a remote branch because the work is over and I don\'t know, I won\'t do a git fetch --prune and eventually I will push back the deleted branc
Since git 1.8.5 (Q4 2013):
"
git fetch" (hence "git pull" as well) learned to check "fetch.prune" and "remote.*.prune" configuration variables and to behave as if the "--prune" command line option was given.
That means that, if you set remote.origin.prune to true:
git config remote.origin.prune true
Any git fetch or git pull will automatically prune.
Note: Git 2.12 (Q1 2017) will fix a bug related to this configuration, which would make git remote rename misbehave.
See "How do I rename a git remote?".
See more at commit 737c5a9:
Without "
git fetch --prune", remote-tracking branches for a branch the other side already has removed will stay forever.
Some people want to always run "git fetch --prune".To accommodate users who want to either prune always or when fetching from a particular remote, add two new configuration variables "
fetch.prune" and "remote.":.prune
- "
fetch.prune" allows to enable prune for all fetch operations.- "
remote." allows to change the behaviour per remote..prune The latter will naturally override the former, and the
--[no-]pruneoption from the command line will override the configured default.Since
--pruneis a potentially destructive operation (Git doesn't keep reflogs for deleted references yet), we don't want to prune without users consent, so this configuration will not be on by default.