![]() From PC1: It checks to see if any uncommitted changes are on PC1.Here's the process this script uses (ie: what it's actually doing) It backs it up first instead! Read more below for how that works. It's safe too, because it doesn't overwrite or delete anything that is uncommitted. That's it! About 30 seconds later everything will be magically synced from PC1 to PC2, and it will be printing output the whole time to tell you what it's doing and where it's doing it on your disk and on which computer. Now cd into any directory within the git repo on PC1, and run: sync_git_repo_from_pc1_to_pc2 Here's some helpful links:Įnsure your ssh keys are all set up to ssh from PC1 to PC2. Git clone your repo you want to sync on both PC1 and PC2.Įnsure your ssh keys are all set up to be able to push and pull to the remote repo from both PC1 and PC2. PC2_SSH_HOST="my_hostname" # explicitly type this out don't use variables PC2_SSH_USERNAME="my_username" # explicitly type this out don't use variables PC2_GIT_REPO_TARGET_DIR="/home/gabriel/dev/eRCaGuy_dotfiles" # explicitly type this out don't use variables # explicit instead just avoids this problem. # happen on the local machine when what we need is the variable expansion from the remote machine. This is because the variable expansion will # - Do NOT use variables such as `$HOME`. ![]() # and you must have *already `git clone`d* a copy of your git repo into it! Here are the parameters it contains: # The git repo root directory on PC2 where you are syncing your files TO this dir must *already exist* Now edit the "~/.sync_git_repo" file you just copied above, and update its parameters to fit your case. Install the script on PC1 (this solution assumes ~/bin is in your $PATH): git clone It is far far far faster than rsync, more trustworthy in my opinion because each PC maintains a functional git repo, and uses far less bandwidth to do the whole sync, so it's easily doable over a cell phone hot spot without using tons of your data. So far it works very well and I'm very pleased with it. I wrote a bash script to automate the process by using git to automatically push changes from PC1 to PC2 via a remote repository, such as github. So, how do I do it? What workflow should I use? If you have this question too, here's the workflow that I decided upon. I tried rsync, but it was insanely slow for large repos and took tons of bandwidth and data. I need a tool to easily synchronize from PC1 to PC2. Let's call the first computer where I write the code "PC1" (Personal Computer 1), and the 2nd computer where I build the code "PC2".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |