I am using git-flow
and what it does is that it deletes my feature/abc
branch whenever I do :
git flow feature abc finish
It deletes the feature/abc
branch after merging it with develop
branch. After that I push my develop
branch.
git push origin develop
Now, on the remote I am able to see the feature/abc
branch, but not locally. So, does that means it deleted from local repo and that delete didn't got carried to remote ?
In my understanding :
Conflict:
=> Assume I am the sole developer on the code.
Update
My question is that I deleted the branch locally post merge. then I pushed the branch to which I merged, then why didn't that reflect on the remote ? Since, GIT is DVCS and should be identical on push / pull. [ Considering I am the only dev ]
I didn't asked to create it either. It made the branch made my changes, merged it back then deleted the branch and pushed my updated develop branch. So, if it automatically detects the creation of those branches then why not the deletion ?
Since, GIT is DVCS and should be identical on push / pull.
No, that’s not really true. It is distributed so each repository within the net more or less contains the same data, but only more or less. When you use push and pull, you explicitely specify what is being pushed.
git push remote branch
only pushes the the branch pointer branch
to the remote repository and transfers all commits the remote repository needs to construct it, but not more. This means that only the commit the branch points to and all parents are actually pushed until the remote repository finds a common parent that it already has (in the worst case, this is the special zero-commit, i.e. the empty parent).
In the same way git pull remote branch
only fetches the changes required to construct the remote branch remote/branch
locally.
To really get all commits, you can use git fetch
, and to push all local branches you can use git push --all
. But again, it only fetches/pushes the commits necessary to construct the branches (or tags), not everything the repository has.
Now, when you push branches to the remote repository it will update only those branches you actually pushed, so when you deleted a local remote and push with --all
, then only your local branches are pushed, and that does not include the deleted one. So your local Git does no longer know which branches you locally deleted (because they were merged) and as such cannot give that information to the remote repository automatically. What it can do however is tell the remote repository every branch it locally has so the remote can figure out which was deleted. You do this by using the option --prune
. Note however that this removes all branches that do not exist locally, so it might make problems when working with multiple users that push different branches but don't pull the other ones (I actually never tested that though).
The best thing is obviously to remove locally deleted branches directly:
git push remote :branch