Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep a git mirror in sync (including deleting branches)?

I've cloned a git repo using git clone --mirror, and I'd like to keep the mirror up to date. So far, I've been using git fetch --all, but I've noticed that branches deleted in the original repo are not deleted in the mirrored repo. I've looked at How to update a git clone --mirror? but my attempt at using git remote update didn't appear to work - branches that were deleted in the original repo are still visible in the mirrored repo.

like image 845
ncdc Avatar asked Aug 15 '11 17:08

ncdc


People also ask

Does git pull remove deleted branches?

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

How do you mirror in git?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.

Is there a git sync command?

git-sync is a simple command that pulls a git repository into a local directory. It is a perfect "sidecar" container in Kubernetes - it can periodically pull files down from a repository so that an application can consume them.


1 Answers

Use git remote prune remoteName to remove the remote branches.

You can also add the --prune tag to git remote update

like image 157
Andy Avatar answered Sep 24 '22 00:09

Andy