0

Apologies in advance for what's probably an obvious question but I don't want to risk screwing up our repositories testing this out.

I need to add another machine (MacBook) to my workflow. I'm wondering if it's better to create a new git user for that machine or if I can continue to use my primary Git username and assume the repositories are smart enough on each machine to remain in sync?

Both machines will be checking code in and out of same server (and, because it's Git, I suppose they could check code out directly from each other?!?)

The other solution, which seems like it might be difficult to juggle, would be to sync the development directories between the two machines with rsync or Portable Home Directories (PHDs via OS X Server).

Thoughts?

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
Meltemi
  • 37,979
  • 50
  • 195
  • 293

2 Answers2

2

if I can continue to use my primary Git username

Git in itself does not have usernames. It only has author/committer names and email addresses that are solely used to identify the author or committer. It does not involve actual authorization or other things. In general, you should keep both settings consistent across your machines, so all your commits still stay attributed to you (the person) and are not dependent on the machines you created the commits with.

the repositories are smart enough on each machine to remain in sync?

Well, they won’t do that automatically, but you can pull and push to the repositories as usual to keep them updated.

Both machines will be checking code in and out of same server

That way you have, next to your two local repositories (one on each machine), a centralized repository which is perfect to keep your local ones in sync with each other. So whenever you have new stuff on one of your local repositories, just push to the centralized repository and that way you can fetch it with the other repository.

because it's Git, I suppose they could check code out directly from each other

Yes, as Git is decentralized, any repository can work as a remote repository. All you need is a network connection to that repository (e.g. private LAN with Samba shares) and you can fetch and push to it.

poke
  • 369,085
  • 72
  • 557
  • 602
1

You want your work to be identified uniquely no matter where you are typing, so use the same name and email when you git config --global user.name/email. I would make a new ssh key pair though. It's not a good idea to copy private keys around. If using github, add the new public key to your keys collection on your user settings on github.

Keeping the repos in sync is a manual process. Each will have tracking branches that mirrors what is on the remote(s) after you git fetch. You can then merge or rebase or ignore and erase your changes as you wish. I would look up the DAG (directed acyclic graph) to understand better how git stores history and how you can manage changes: http://eagain.net/articles/git-for-computer-scientists/

You can push and pull from the 2 machines you use quite easily. Just add a remote for the other one on each. You will most likely be pulling as pushing to non-bare repos is not a good idea. This hinges on the fact that you can see one machine from the other and this may involve VPN access, etc. But it's still possible to move changes without using the 3rd repo via patches or bundles. git bundle is very easy to use and I've resorted to emailing myself bundles. There is dropbox for that too. Many people use that option.

Community
  • 1
  • 1
Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • agreed. i use unique keys for every machine. i think i have 5 different keypairs on github. – xero Jan 03 '13 at 16:42