Reputation: 6251
How should my local Git workflow look?
I'm using it to develop some software that will run on a local server. I'd also like to use this server as the git repo host.
So far I've initialized a new repo on the server using --bare and pushed my current code to it.
How do I checkout that code to a directory on the server (i.e. /var/www/)?
I gather I should create a development branch, which I then get using git pull on my development machine, then create a release branch from the development branch when I'm nearing completion of a certain set of features. This release branch will then be merged with the master (live/production) branch - as per the workflow described here.
My Main question (above) is: How do I checkout code from my bare git repo to my live directory on my server?
Upvotes: 0
Views: 459
Reputation: 1317
I suggest you set up a bare repo on the server that hosts your live-site as well.
To get started with working you clone that bare repo to you local development-machine
localhost:~# git clone you@yourlivehost:/path/to/bare /path/to/local/dev
Inside that repo you do all your development/committing/branching/merging stuff and when you are done you push to the bare-repo.
You can either login to your live-server manually and pull the changes from the bare repo into you live-service or let a post-update-hook do the job for you.
Manually (first-time):
localhost:~# ssh you@yourlivehost
yourlivehost:~# cd /path/to/live/server
yourlivehost:/path/to/live/server# git clone /path/to/bare .
Manually (the other times):
localhost:~# ssh you@yourlivehost
yourlivehost:~# cd /path/to/live/server
yourlivehost:/path/to/live/server# git pull
This assumes that you work on master all the time. If you follow a more complex branching strategy (as described in the link you provided – wich is the same strategy I like to use, by the way) you have to make sure you merge all the desired changes from branch development to master before you push from local development host to the bare repo.
To have a hook automatically do this for you edit the file /path/to/bare/hooks/post-update
and fill in something like
cd /var/www
git pull origin
Make sure the file is executable and the user you use to run the repo has write permission to the webserver-directory.
Upvotes: 1
Reputation: 876
Try this:
git clone file:///path/to/your/bare-repo
or this between hosts:
git clone user@host:/path/to/your/bare-repo
Upvotes: 0
Reputation: 3980
Look at gitolite! It's convinient method of organizing own git server locally or on remote machine with access by keys. So in future when you will need to add somebody one of your repositories it willn't be a problem.
Upvotes: -1
Reputation: 7795
I hard-link the contents of my GIT repo to my live installation.
Check out my gist: https://gist.github.com/2652879
I execute this in my htdocs directory, after i updated all my repos. This way i always have the contents of the repos in my live install, can make changes in the live installation and when they are good, commit them without any more work.
This has the nice advantage to the previous anserws that i do not have a repo directly in my live installation, but only the files from it.
Upvotes: 0
Reputation: 131811
How do I checkout that code to a directory on the server (i.e. /var/www/)?
For example
cd /var/www && git clone /path/to/repo .
How do I checkout code from my bare git repo to my live directory on my server?
cd /var/www && git pull
Upvotes: 1