Problem description: in Visual Studio in Team Explorer I create a new branch, come back into it some changes and make Publish this branch on GitLab. There I create Pull Request after which I create a branch in master, and after I delete the branch. Then in Visual Studio I do a Pull and the changes made appear in the master branch. If you look at the Branches tab in Team Explorer, then the branch that was deleted on the remote repository remains to hang in the list.

enter image description here

I can bring up the context menu on the branch and delete it manually. But even if so, I do not understand why these branches remain with me in remotes / origin.

Question: Should branches be deleted locally automatically after I deleted them on the remote repository? Or is this normal behavior and should I delete them myself?

  • And if to make fetch of this branch? - Monk
  • just as it turns out. I recently started to deal with git, first I looked at how to work through the console with him, I didn’t have such a problem, but I really had several local repositories there. - Yankov Viacheslav
  • 2
    The first rule of the gita is not to use guts. pull by default pulls only the current branch. He does not touch deleted. If you want to clear remote branches, use the --prune parameter. If you want it to be automatic, set git config remote.origin.prune true - KoVadim
  • 2
    @syler through gui is convenient to merge, because everything is clear. If it’s just hellish (many files, many conflicts), then maybe you just do them too rarely. Think about splitting up tasks into smaller fragments, respectively, you will merge feature branches back into a stable branch more often and with fewer changes. - Nick Volynkin
  • 2
    But in general, I agree with @KoVadim - learn to work with the console, it gives more control and accuracy. And I also recommend to study how the guitar is arranged inside. When you have a clear model in your head of what you are doing and you get used to thinking in terms of graphs , it will be much easier for you, even on large projects with a complex history. - Nick Volynkin

1 answer 1

The first rule of the gita is not to use guts. To be more precise, do not use guts for actions that modify the repository. In case of any inconsistencies - immediately to the console.

pull by default pulls only the current branch. simple policy . He does not touch deleted. If you want to clear remote branches, use the --prune parameter:

 git pull --prune 

or

 git fetch --prune 

If you want it to be automatic, set git config remote.origin.prune true in the config git config remote.origin.prune true .

If you live big and scary, then in the team someone does not do what is necessary. Crush tasks into small features, regularly add a master (develop) to your branch.

Finally, look at git flow !

  • one
    Two hands for small features and git flow. ) - Nick Volynkin
  • Thanks for the answer again! - Yankov Viacheslav