How to avoid reoccurring branches?

Let Project A exist with branch 1 and 2 on the remote.

If person X and Y both clone the project, they both have a version of Project A with the two branches on their PC.

If person X removes branch 1 locally and pushes these changes, branch 1 also disappears remotely.

If person Y now pushes their changes of branch 2, branch 1 gets added as well.

How to avoid this behavior, any suggestions?
Thank you.

If you’re using Git directly, using command git status will tell you what changes you’re making, so the 2nd person would see that they’re uploading branch1 changes. However, they may not know that the first user removed the branch.

One way to reduce the number of times this happens is to always pull the branch before starting work. this way, your local branch is up-to-date with the repository, including deletions. This will not prevent this from happening if both people work on the project at the same exact time, but it will prevent overwrites when another user changes things later.