![]() ![]() Or viewed differently, go PC A -> USB -> PC B In reality I backup multiple projects to multiple locations, but it's only the repeated USB items that are relevant here.Īnother thing that is rather obvious but that I have not seen mentioned, is that in order to sync PC A and PC B, you'd need to 1. I run this for backup purposes so I've only shown the push side of things, and reduced the number of projects and repositories. There is no defaulting to master or needing to know the names of branches and handling them one by one. The push -all and push -tags command do this synchronizing, making sure that all the branches and tags are pushed to the USB repository, even new ones that the USB repository was unaware of. I don`t want to send this branches to remote server, just keep them local. The original question said: I have some local branches on every one of them. (The -d flag is checking for existence of the git repository directory and conditional code only executes if the directory exists.) The intention is to push all branches and all tags to the USB repository if it exists and where ever it is. I then run a script with contents like this cd /path/to/projectname USB_G file:///g/Git_repositories/projectname.git (push)īasically I have defined several remotes with USB names rather than just one as suggested since the drive letter allocated to my USB device changes depending on the port I insert it into. USB_G file:///g/Git_repositories/projectname.git (fetch) USB_F file:///f/Git_repositories/projectname.git (push) I get information like this USB_F file:///f/Git_repositories/projectname.git (fetch) The information in other posts seems right, but I'd like to mention a few extra things I do in practice. I'd just like to add a little twist to things. # updating from a remote repository configured using the above command Git remote add usb file:///path/to/usb/stick/repository.git # adding the USB stick repository as a remote for an existing repository # updating a repository cloned from the USB stick using the above command Git clone file:///path/to/usb/stick/repository.git On the receiving end, mount the USB stick, and use a file URL for the repository file:///path/to/usb/stick/repository.gitĪ few handy commands: # cloning the repository on the USB stick Just make sure it's mounted :) For instance, the following pushes new changes to the USB repository. In the future, you can treat the USB repository as any other remote repository. git remote add usb file:///path/to/usb/stick/repository.git Then register the repository on the USB stick as a remote repository, and push the desired branch to it (if you don't want to push master, substitute your desired branch). Start up by creating a repository on the USB stick. This post describes a method for pushing changes between two repositories without using a server with network connections to both hosts having repositories See this blog post "Synchronizing Git repositories without a server " (by Victor Costan). You then transfer the bundle to the other machine to replace /home/me/tmp/file.bundle, and pull from it. MachineA$ git bundle create file.bundle lastR2bundle.master To update the resulting mine.git repository, you can fetch or pull after replacing the bundle stored at /home/me/tmp/file.bundle with incremental updates.Īfter working some more in the original repository, you can create an incremental bundle to update the other repository: machineA$ cd R1 The $GIT_DIR/config file in R2 will have an entry like this: įetch = refs/heads/*:refs/remotes/origin/* This will define a remote called " origin" in the resulting repository that lets you fetch and pull from the bundle. machineB$ git clone /home/me/tmp/file.bundle R2 The bonus is that it does have some of the characteristics of a bare repo: you can pull from it or clone it, but you only have to worry about one file. Rather than making a bare clone, I prefer making a bundle (see " How can I email someone a git repository?"), which generates one file, easier to copy around (on an USB stick for instance). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |