Why are remote branches not deleted on the remote after clicking?

I use git-flow , and what it does is that it removes the feature/abc branch whenever I do:

 git flow feature abc finish 

Deletes the feature/abc branch after merging with the develop branch. After that I click the develop branch.

 git push origin develop 

Now on the remote, I can see the feature/abc branch, but not locally. So, does this mean that it was deleted from the local repo and that the removal was not transferred to the remote?

In my mind:

  • Since git is distributed, so the whole repo exists on all machines.
  • So, if I make changes to my local repo and push it to a remote computer.
  • Then all my changes should be transferred to the remote, including deletion.

Conflict:

  • How local and remote git repository will be different after clicking.

=> Suppose I am the only code developer.

Update

My question is that I removed the local branch merge. then I pushed the branch to which I merged, then why it did not affect the remote? Since git is DVCS and should be identical on push / pull. [Considering I'm the only dev]

I did not ask to create it either. This led to the branch making changes, merging it, then deleting the branch and pushing the updated development branch. So, if it automatically detects the creation of these branches, then why not delete it?

+4
source share
1 answer

Since GIT is DVCS and should be identical on push / pull.

No, it is not. It is distributed in such a way that each repository on the network more or less contains the same data, but only more or less. When you use push and pull, you explicitly indicate what is being pushed.

git push remote branch only pushes the branch branch pointer to the remote repository and passes all the commits that the remote repository should build, but no more. This means that only the commit indicates a branch, and all parents are actually pushed until the remote repository finds the common parent that it already has (in the worst case, this is a special zero-commit, i.e. an empty parent).

Similarly, git pull remote branch only retrieves the changes needed to locally create the remote remote/branch .

To really get all the commits, you can use git fetch , and to push all the local branches you can use git push --all . But then again, it only pulls / pushes the commits needed to build the branches (or tags), and not everything that the repository stores.

Now, when you push branches to the remote repository, it updates only those branches that you actually pressed, so when you deleted the local remote and pressed using --all , then only your local branches will be pressed, and this does not include remote. Thus, your local GIT no longer knows which branches you have locally deleted (since they were merged) and as such cannot automatically transfer this information to the remote repository. However, it can tell the remote repository that each branch locally has it, so the remote can determine what was deleted. You do this using the --prune option. Note that this deletes all branches that do not exist locally, so there may be a problem when working with multiple users who push different branches but do not pull others (I actually never tested this).

It is best to explicitly delete locally remote branches directly:

 git push remote :branch 
+5
source

All Articles