问题描述:

I am doing my first steps in git with some personal coding projects. What I want to do is to be able to clone the main folder of each project in all computers that I have. I am basically working from a MAC at home, a Windows machine at work (where I am planning to create an ubuntu VM and run everything there), another one ubuntu machine at home and an ubuntu VPS. I also own a bitbucket account.

The only thing I have succeeded is install git on my main MAC and add/commit/push data on the remote bitbucket repo. What steps should I follow to achieve what I want ? Do I clone the main bitbucket repo in all computers with fetch/pull? Or do I set all other computers except my main MAC one as remotes and push to all from here ?

网友答案:

You clone with git clone and run git pull in each downstream repo periodically to update the slaves.

If you can SSH into all your boxes, you could equivalently push from the master, but the way access controls at ISPs etc are usually done, this is often not feasible in practice.

Keep in mind that Git is decentralized. Don't needlessly give your Mac a special position in the topology. If you prepare mentally for the eventuality that any one of the clients could push to master, you will be glad one day that you didn't paint yourself into this particular corner. This will be more of a mental exercise than a technical one; if you are used to a centralized topology, it's a bit of an effort to get into the habit (mainly, don't depend on anything which isn't up to date in the master repo, or easily obtained independently on any client system. Basic hygiene really).

网友答案:

Use your BitBucket repo as the central repo and push/pull from there on every machine you're going to use.

That way the BitBucket repo is the source of truth. Also, it will be accessible from basically anywhere, whereas if you do work on one machine that is a remote and you move to another one you might not be able to pull from your Windows machine.

相关阅读:
Top