MySpace
  • Home
  • Profiles ▼
  • Communities ▼
  • Apps ▼
  • Metrics
  • Moderation
  • ▼
  • Log In
  • Share
  • ?
  • HCLHCL

Blogs

  • My Blogs
  • Public Blogs
  • My Updates
  • Administration
  • Log in to participate

▼ Tags Topic Tags

 

▼ Archive

  • August 2024
  • July 2024
  • June 2023
  • September 2021
  • August 2021
  • July 2021
  • January 2021

▼ Blog Authors

New Horizons

View All Entries
Clicking the button causes a full page refresh. The user could go to the "Entry list" region to view the new content.) Entry list

Efficient code replication between two folders

Jayanth Boddu 02F71794-8F71-4622-6525-7BA70043E8EB Boddu_Jayanth@ongc.co.in | ‎ | 1 Comment ‎ | 239 Views

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​

Modified on by Jayanth Boddu 02F71794-8F71-4622-6525-7BA70043E8EB Boddu_Jayanth@ongc.co.in
  • Add a Comment Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry
Notify Other People
notification

Send Email Notification

+

Quarantine this entry

deleteEntry
duplicateEntry

Mark as Duplicate

  • Previous Entry
  • Main
  • Next Entry
Feed for Blog Entries | Feed for Blog Comments | Feed for Comments for this Entry
  • Home
  • Help
  • Bookmarking Tools
  • Mobile UI
  • About
  • HCL Connections on hcl.com
  • Submit Feedback