4

just starting to get into git, I am wondering that the best solution for working on multiple machines is.

What I need to be able to do is:

  • Start projects on any machines and then sync them across to other sites
  • Utilise branches to make location specific changes, whilst being able to commit required changed to central repo on github.

What commands do I need to get my head around?

Mild Fuzz
  • 29,463
  • 31
  • 100
  • 148
  • 1
    commit, fetch/pull/push, merge – knittl Nov 08 '10 at 10:47
  • in the first instance, when starting work on a second machine, should I use pull? – Mild Fuzz Nov 08 '10 at 11:18
  • As knittl said, for transporting between repos, it's pretty much just pushing and pulling (pull is fetch+merge). The thing you may have to take a little more time to look into, if you're pushing and pulling between your own machines, is the various transport mechanisms. Git can use ssh (probably easiest for self-administration) as well as http(s) and the git protocol. – Cascabel Nov 08 '10 at 14:53

2 Answers2

1

For multiples machines, with no direct LAN access, GitHub is the right intermediate repos, with WAN access and user ACLs.

The working with remotes GitHub help page will gives you the first commands, to declare your GitHub remote upstream repo, toward which all your downstream repos (on your different machines) will push to/pull from.
On the second machine, you will start with a git clone.

To grab a full copy of another user’s repo when you do not have a local repo already, you will use git clone URL.

  • For public repos, the URL can be a read-only URL like git://github.com/user/repo.git or an HTTP read-only URL like http://github.com/user/repo.git.
  • For public repos you own or are a collaborator on, and all private repos, you must use a private ssh url like git@github.com:user/repo.git.

That being said, branches should be made to isolate development effort, not to isolate environment-specific text files (like config files).
For the latter (configuration), keeping one branch with:

  • a template config file
  • a value file (with the values for the different environments)
  • a script able to extract the right values and generate the final config file

is a better alternative.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • does this address the need for having the same ssh key on multiple machines? What is the same key/acct cannot be used across machines? – CrackerJack9 Jan 11 '12 at 02:53
  • @CrackerJack9 Using the same ssh key is addressed in http://stackoverflow.com/questions/8753014/how-to-setup-github-ssh-key-on-second-computer – VonC Jan 11 '12 at 05:08
0

Git will definitely be able to handle your need, and in my opinion is the best and most flexible SCM you can choose.

If you have push access on all the other repos, it is a simple matter of pushing to each one them with the new changes. Or you could easily impose a centralized modal (easy to set up via service like GitHub) and only push to the central repo and either cron the other repositories to pull from the central repo or just tell developers to pull from there on a regular basis.

The official git site has great documentation on the few commands you'll really need to get started.

Enjoy!

dkinzer
  • 32,179
  • 12
  • 66
  • 85