Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (29.3k points)

If someone deleted a remote branch because the work is over and I don't know, I won't do git fetch --prune and eventually, I will push back the deleted branch.

Is there a viable solution for forcing git to use the prune mode when fetching / pulling without having to specify it every time?

2 Answers

0 votes
by (50.2k points)

 * "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.

From the release notes of version 1.8.5. Clearly says that for this question you need to set remote.origin.prune to true:

git config remote.origin.prune true

Now, after running the above command Any git fetch or git pull will automatically prune.

Note: But in the previous version of git this command will add a bug related to this configuration and which makes the git remote rename to misbehave.

0 votes
by (140 points)

If you want to have ‘prune’ executed with every fetch operation, you can configure git accordingly:

$ git config --global fetch.prune true 

Use git prune command to  clean up local branches

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories