Rai Arslan
Rai Arslan

Reputation: 5

Merging and Deleting Feature Branch From Azure and Local Machine Repository

Here is the scenario

  1. I am the only developer in my team (stated to make it clear that there will be no change from other team members to consider)
  2. have a main branch stable and deployed on production server
  3. created a feature branch add some other features and changes into existing business flow
  4. Everything looks fine, now I wanted to merge these all new features to main branch

  5. Committed and synced on server all news changes are going to feature branch

  6. Created a pull request and approved it, it deleted feature branch from server but it still exists on Local machine
  7. The question is How to merge all changes into main branch and delete feature branch on local machine as well?

Upvotes: 0

Views: 1449

Answers (2)

Rongdan
Rongdan

Reputation: 174

We can just delete the remote-tracking branches at VS with the command "git config remote.origin.prune true" or set the "Prune remote branches during fetch" combo (Team Explorer->Settings->Git Global Settings) is true.

The various prune options (git remote update --prune, git remote prune, git fetch --prune) only delete remote-tracking branches.

If we want to deleted the local branches, we can only delete them manually.

You'll need to manually delete local branches you no longer want, or change or remove their upstream setting if the remote-tracking branch no longer exists.

For more details, you can rewards here: git fetch origin --prune doesn't delete local branches?

Upvotes: 1

Chad B
Chad B

Reputation: 1506

After completing the PR and having the remote feature branch deleted, you'll need to do a fetch into your local clone. By default, the remote tracking branches in the local clone aren't deleted. You can call "git fetch --prune" to do that cleanup.

If you have a local main branch, you'll need to pull it from the remote main branch to get it up to date.

If you would like to have fetch always prune, you can set a config option to force this behavior. Team Explorer includes the ability to set this in the UI. Team Explorer->Settings->Git Global Settings, and look for the "Prune remote branches during fetch" combo.

Hope this helps.

Upvotes: 0

Related Questions