I have a git repository on a server somewhere where I keep long term changes to my software. I develop this software on an Windows machine using Visual Studio. I make commits via Visual Studio and push changes to the server via a Git CLI tool. This software is mainly used on an offline machine, though some development and bug fixes are done on this offline machine.
The problem I currently have is two fold. First, it takes quite some time to copy the entire Visual Studio project folder (which also is the .git repo) from the online development machine to the offline machine, especially in view of small changes to the codebase (Sometimes I simply copy over files directly). Second, I frequently forget to move changes/"production bug fixes" (yea) from the offline machine back to the development machine.
After starting to post a question about how I might do this via git (Updating local repository from another local repository ) I found a few duplicate questions, namely this question. It provides a descent selected answer, but I am more interested in this answer. It proposes creating a --bare
git repository.
My question is, in the situation outlined above, is this the correct way to implement and use a --bare
repository to solve my issues?
- On the development machine, create a clone of either the remote master repository from the server or the local repository, but with the
--bare
argument (git clone --bare /my_remote_path/project.git
). - Add this repository as a/the origin to the working git directory already in place (
git remote add origin /my_local_path/project.git
). - During regular development push changes to this local,
bare
, repository and to the remote repository withgit push origin master
(to the server) andgit push origin
(to the local--bare
). - To move changes from the development machine to the offline machine, copy the entire
bare
repository folder to the offline machine. On the offline machine add thebare
repository as a/the origin (git remote add origin /my_local_offline_path/project.git
) - Push and pull changes on the offline machine from this new origin,
git pull origin
/git push origin
. Though this obviously won't effect untracked files, which is fine. - Finally, to move changes from the offline machine to the development machine, copy the entire
bare
repository folder to the development machine. On the development machine pull changes from the local working repository usinggit pull origin
. To save changes to the server push from local working directory to the servergit push origin master
.
This workflow seems correct to me, though the only thing I think is completely incorrect is the push/pull commands to and from the bare
repository; especially with regards to the local working directory on the development machine (How to denote push/pull from the server or the bare
repository).