简体   繁体   中英

what is the best way to work across multiple machines with git?

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?

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM