开发者

Is it possible to use Git between two workstations, without a "central" repository?

开发者 https://www.devze.com 2023-01-28 02:11 出处:网络
I made the move from SVN to Git for some home programming, setting up a Git repository on my ReadyNAS drive. I then created a repository, which I cloned onto two different laptops.

I made the move from SVN to Git for some home programming, setting up a Git repository on my ReadyNAS drive. I then created a repository, which I cloned onto two different laptops.

These laptops both have changes that are committed but not pushed back to the central repository; this is because the central repository / NAS drive is on a boat somewhere and won't be seen for 6-8 weeks ! So my question is, in the 开发者_开发知识库meantime, I have both laptops on the same network and would like to push the local repository commits from one laptop to the other.

Is this possible ? I am running Windows on both laptops, and using the "Git Bash" installable on each one.


Yes, sure. A git repository is just a bunch of files and all you need is some way to access them. For example, you could set up a bare "central" repository on one computer's shared folder and then push/pull to/from it from both computer's local clones that you use for development.


Yes, you can. Even without an additional bare central repo on one of the two laptops (wich would replace the original central repo).

The only drawback when working without a bare central repo is that you cannot push back to a checked out branch. Say, you're working on master on both laptops and cloned the repo on laptop2 from laptop1.

Before pushing back changes from laptop2 to laptop1, you have to do a

laptop1> git checkout other_branch

on laptop1 first, before you can execute the push.:

laptop2> git push 

Otherwise the push will fail 'cause you cannot push to a checked out branch. After the push, check out master again on laptop1.

0

精彩评论

暂无评论...
验证码 换一张
取 消