Git from localhost to remotehost with a team of three
I'm completely new to Git.
I've only just worked out how to use Github in a basic way (e.g. push my local file changes to Github - so I've not done 'pulling' down of content from Github and 'merging' it into my localhost version or any开发者_如何学编程thing like that).
I had a look over at this existing question - Git: localhost > remote development > remote production - but I think it may have been a bit advanced for me at this stage as I didn't quite understand the terminology that most of the people were using.
What I would like to achieve is to have a local server set-up that my team of developers can all 'push' to/'pull' from etc. And then have that local server upload any updated files automatically to our web server so we could see the updates live in the browser.
I'm happy to get a server set-up in the office running Mac OSX Server and then installing Git on it and then getting the devs to write a shell script to push to the remote server but only if it was fairly easy for the devs local git to push to this new local server.
I'm not a network engineer so I don't know what would need to be set-up for that to work, I know obviously we could set-up the server to be accessible via a local ip address like 192.168.0.xxx but not sure how that works with pushing to a git repository on that server?
Would that literally be something like doing this on my local machine:
git remote add MyGitFile git://192.168.0.xxx/MyGitFile.git
?
Any ideas or advice you can give to a total Git newbie trying to help his team get a better work flow.
Kind regards, Mark
This is a relatively advanced topic but you should research Git hooks. You will likely need to use a Git post-receive hook, and depending on if the repository and the web server live on the same box, a bit of scripting to do the update. See, http://toroid.org/ams/git-website-howto for example.
In reply to 'farnoy' (sorry I can't seem to reply to people on StackOverflow without having 50 hits?)
What is the bare version of repo? I've set-up a shared folder over an ip address on our local network (I'm on a Mac) and I've:
git init
in the relevant folder, but I don't know how to get the URL of that .git?
Any help appreciated.
I think for our purposes, doing it over our localhost will work fine but I'm still fairly new to Git so I don't quite understand the 'bare version repo' or what that does?
Thanks.
M.
I think it's easiest to setup a git shared repo with a HTTP server. You probably already have it, so try http://localhost with your browser. Just put your bare version of repo where HTTP server have access to it, then you can use:
git clone http://192.168.your.ip/path/to/repo.git
On your computer, clone the same repo, commit and use it as you want, then push back to the shared repository.
I would suggest you to use gitosis for your local git server. This way developers will be able to push and pull over ssh with public key authentication (like on GitHub).
Instead of a dedicated web server it can be more convenient to setup Gitweb on the same server. Gitweb enables you to view repositories/branches/updates easily (example)
Both applications are available as packages on Debian and can be easily installed and set up. However installation can be harder on Mac OS X but there are many how-tos for both apps.
精彩评论