I have a specific scenario where my Windows machine has access to the remote repository just fine, but my Linux 20.04 VMware instance does not (This is intentional, and for the sake of this question, not something I can control)
I'd like to know if there is any specific work around where I can still use git normally within my VM, and still have it track the remote repo.
I've attempted to use git clone --bare git.myremoterepo.com, then clone that into my VMware by storing that file in Shared Folders
of VMware. Which worked great, but obviously the bare repo is severed from the remote repo, and at the same time, any commit are made to the bare repo, and not to the remote repo. (Unsure if they can be carried over?)
Linux is my dev environment, so I would need to have the repo on my VM,
Any suggestions?
obviously the bare repo is severed from the remote repo
It is not. You can git fetch
into the bare repo, and you can git push
from the bare repo to the upstream repo. It has the remote URL already configured like a normal clone would.
Your commits aren't made directly to the bare repo, they're made to the regular clone that you're working in – the process of committing doesn't care about other repositories. You transfer those commits to the bare repo as a separate step, by pushing them. You can repeat that step to transfer the same commits to yet another repo, by pushing from the bare repo. (That is, commit to A, push A→B, push B→C.)
Similarly, you can fetch commits from upstream into the bare clone. (Not pull, as bare repos have no worktree so there's nothing to merge into.) Instead of the remote-tracking branches being separate, your bare clone has a 1:1 mapping, so that the upstream's 'main' branch is directly fetched the bare repo's 'main' branch (not to origin/main).
Note though that fetch is by default configured to overwrite local contents (i.e. allow non-fast-forward fetches). If you first push your changes into the bare repo, then try to fetch upstream changes, your pushed commits will get discarded from the bare repo (though not from the VM repo of course) – the fetch command will print a "non-fast-forward" notice. In such situations you'll need to go back to the VM and pull (merge) from the bare repo as you normally would from upstream, then repeat the push. It might be a good idea to always fetch upstream updates into the bare repo from Windows before pushing from the VM.