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.
Asked
Active
Viewed 7,513 times
6
2 Answers
10
Use git remote prune remoteName
to remove the remote branches.
You can also add the --prune
tag to git remote update

Andy
- 44,610
- 13
- 70
- 69
-
Works perfectly, thanks! FYI, the message is not clear, but it does exactly what's asked in the question: it removes local references that are not present anymore on the remote side – jbbarth Jun 05 '13 at 14:23
-
@Andy does update keep my changes or does it overwrite something? – David Trevor Jul 08 '16 at 14:02
-
update shouldn't change any commits on your computer. all it does is fetch new updates for branches on your remote repositories. – Andy Jul 08 '16 at 14:24
0
I go one step further and configure it globally:
git config --global fetch.prune true

Ivan
- 9,089
- 4
- 61
- 74