[Git] Is VCS > Git > Fetch always done with pruning?

Answered

Hello!

My question is: is fetching always done with pruning in Intellij Idea? (Equivalent of "git fetch -p")

The evidence for it would be: 1) that's how I observe it behaves, 2) this post: https://youtrack.jetbrains.com/issue/IDEA-77857, the last comment.

If it is really so, is it configurable?

Why I am asking. Maybe I am doing it wrong, but I run VCS > Git > Fetch from time to time to "get new branches" (that's the only way I know how to do it). Then imagine this situation: I have some branches that are important to me and I would never delete them. Imagine that somebody by mistake deletes the (remote) origin of my branch. This means: the next time I do fetching, Idea will call git with parameters that will delete my precious branch. If Idea didn't do this pruning, I would at least have my branch locally and could push it to remote again.

This scenario looks like a HUGE problem to me and I fail to understand why it's done so, but maybe I am missing something since apparently nobody complains. I also could not find much information on this topic (like is fetching always done with pruning, and what's the rationale behind that), apart from the quite old and suspiciously quiet link I pasted above.

Thank you!

 

Best regards,

Andrey Starikov

0
2 comments

You can always lookup the exact commands in the Console tab in the Git toolwindow (Version Control in earlier versions).

Yes, IDEA calls the fetch command with the --prune flag, and it is not configurable.

But it only removes references to remote branches (files from the .git/refs/remotes folder). If a branch is removed on the remote, there is a little sense to keep a reference to it, as it points to nothing.

This flag does not remove your LOCAL branches (files from the .git/refs/heads folder). It also does not remove tags.

See https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---prune and https://git-scm.com/docs/git-fetch#_pruning

So if you want to keep something locally, checkout a local branch or set a tag.

1
Avatar
Permanently deleted user

Yes, thank you very much for the detailed answer, I confused how git pruning works.

0

Please sign in to leave a comment.