Reputation: 2332
I am new to git and I fail to understand how can a "git push" command deletes another branch.
There are two branches as you can see below. master and testbranch. These branches were created by two different people. However a "git push" by a user deleted the branch created by another user. Can someone explain how is this possible and what needs to be done to avoid such behavior. For the record, I use GitLab.
Edit: Additional info : The use who is pushing has a mirror configured.
Upvotes: 2
Views: 347
Reputation: 12229
Summarizing the comments into an answer: as you indicated in the chat, the push was done from a mirror, and that is the cause of the problem.
A mirror is meant to be kept in complete sync, so when you push from a mirror, it effectively does --prune
by default. A mirror is not meant to be used as a sandbox, it's meant to be used for backups or other situations where you want a complete reproduction of a repo somewhere else.
When pushing from a mirror clone, every push operation will be done with the --mirror
switch implied, which force pushes everything and prunes locally deleted branches. (Ref: git push manual, look for --mirror
)
Preventing such problems can be done with:
Upvotes: 4