Gabriel
Gabriel

Reputation: 42329

Will 'git push origin <branch>' remove <branch> remotely after removing it locally?

I'm following the git-flow model and I have a doubt.

First, I add a new feature branch from 'develop':

# Checkout from develop branch
$ git checkout -b <branch>
# Push and track <branch>
$ git push --set-upstream origin <branch>

After the feature is finished, I follow Incorporating a finished feature on develop:

# Switch to 'develop'
$ git checkout develop
# Merge <branch> into 'develop'
$ git merge --no-ff <branch>
# Remove <branch> locally
$ git branch -d <branch>
# Remove <branch> remotely <-- ???
$ git push origin develop

The last command is the one that I'm not sure about. Will it remove remotely the <branch> I just removed locally?

Upvotes: 4

Views: 50

Answers (2)

Rick
Rick

Reputation: 96

Thanks for the comment. Now that I understand what you're asking the answer is no. In the git-flow model the feature branch is not pushed to remote, so all actions affect your local git repository.

If you've pushed your feature branch to the remote repo, you'll need to delete it manually.

Upvotes: 1

Makoto
Makoto

Reputation: 106430

No; <branch> is only removed locally by virtue of git branch -d <branch>, but a copy of it exists on remote (if it was pushed there prior). This can be verified by running git branch -vvvv, which will show the remote branch with no associated local tracking branch.

git push origin develop will only push develop to your remote repository (origin) without touching anything else (barring any commit hooks). If <branch> did exist remotely and you wanted to delete it, you would have to add the deletion operation as a separate step (git push origin :<branch>).

Upvotes: 2

Related Questions