Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fetch from origin with deleted remote branches?

Tags:

git

git-fetch

People also ask

Can I delete local branch and pull it from remote?

Deleting a branch LOCALLYThe -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.

Does git pull remove deleted branches?

This is because "git pull" does not remove remote tracking branches for branches deleted from remote repo.

What happens when you delete a remote branch?

Deleting both a local and a remote branchThey are completely separate objects in Git. Even if you've established a tracking connection (which you should for most scenarios), this still does not mean that deleting one would delete the other, too!

Does git remote prune origin delete remote branches?

Does Git Remote Prune Origin Delete the Local Branch? No git remote prune origin will only delete the refs to remote branches that no longer exist. Git stores both local and remote refs. A repository will have local/origin and remote/origin ref collections.


You need to do the following

git fetch -p

The -p or --prune argument will update the local database of remote branches.


From http://www.gitguys.com/topics/adding-and-removing-remote-branches/

After someone deletes a branch from a remote repository, git will not automatically delete the local repository branches when a user does a git pull or git fetch. However, if the user would like to have all tracking branches removed from their local repository that have been deleted in a remote repository, they can type:

git remote prune origin

As a note, the -p param from git fetch -p actually means "prune".
Either way you chose, the non-existing remote branches will be deleted from your local repository.


You need to do the following

git fetch -p

in order to synchronize your branch list. The git manual says

-p, --prune
After fetching, remove any remote-tracking references that no longer exist on the remote. Tags are not subject to pruning if they are fetched only because of the default tag auto-following or due to a --tags option. However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning.

I personally like to use git fetch origin -p --progress because it shows a progress indicator.


This worked for me.

git remote update --prune