Today I learnt very simple trick to use version control across two folders to keep them in sync.
This is particularly useful if you shuffle your coding work between two devices and have been constantly copying changes from one to another. For example, I do most of my GPU heavy computation on a workstation but design and run EDA / cleaning scripts on my Mac. Another situation would be development on the local machine and pushing GPU heavy jobs to a HPC cluster, where you would have to constantly delete & replicate everything in the cluster memory.
To version control in case of personal project, you could you use GITHUB and for a project hosted on the Business Network , you could use git.ongc.co.in , but both of these were not applicable to my case.
So let's say have a project folder A on workstation and you want to keep it in sync with a project folder B on your removable media. These are the steps you need to perform
1. Initialise git in both A and B. -- `git init`
2. Create a new folder C and initialise a barebones version there. -- `git init --bare`
3. Set C as a remote repository of A. -- `cd A` , `git remote add <a name, example : C > <full path to C>
4. Set C as a remote repository of B. -- `cd B` , `git remote add <a name, example : C > <full path to C>
Now if you want to replicate changes of A into B, first you would have to make commits in A and push to C and then pull commits from C into B.
1. `cd A`, `git add .` , `git commit -m '<commit message>'`, `git push <name of remote > <branch name, ex : master>
2. `cd B` , git pull <name of remote > <branch name>
Similarly you can replicate the change made in B to A by doing the opposite -- committing and pushing from B and pulling in A.
In totality, all we are doing here is , we are removing a code hosting server like GITHUB from the picture and using a local repo C to play its role.
You can do this with multiple repositories , multiple branches etc.
Hope this helps someone.
Ref : https://stackoverflow.com/questions/6976459/push-git-project-to-local-directory