I have two local clones of the same remote repository (urlA
):
git clone --mirror urlA mirror
git clone --reference-if-able ../mirror urlA dirB
In dirB, when I run:
git fetch
git push
will mirror/ be updated by either command?
My understanding is that --reference-if-able
only speeds up object downloads by reusing objects from the reference repo, and does not turn the reference into an actual remote that receives fetch
or push
. However, I found elsewhere a comment suggesting it might propagate commands.
Question:
Does --reference[-if-able]
ever trigger fetch
or push
on the reference repository? If not, how can I configure Git so that a single git push
or git fetch
from dirB also updates my local mirror clone?
--reference
/ --reference-if-able
does:When you clone with --reference
or --reference-if-able
, Git borrows object data from the reference repository (in this case, ../mirror
). This is only for performance/memory efficiency — it helps to avoid downloading or storing duplicate objects.
--reference
/ --reference-if-able
does not:fetch
or push
to the reference repo.git fetch
and git push
in dirB will only interact with the remotes configured in dirB/.git/config
, not with mirror/
.So no, git fetch
or git push
in dirB
will not update mirror/
. mirror/
remains completely unaware of what happens in dirB
.
If you want mirror/ to be updated automatically when you fetch/push from dirB, you'll need to explicitly configure that behavior with a custom script or a hook.