Reputation: 15
I started a coding project, which has expanded in size and I want to use Git for version control. If that matters, the project is combination of web infrastructure written in HTML/CSS/PHP and server infrastructure written in C.
I currently work in the following way:
I perform changes in my development directory: /var/www/dev
. Once I am satisfied I manually move the changed files to the live directory: /var/www/stable
. Both stable and dev are currently the same, but are web-accessible through different domains: foo.com and dev.foo.com
I have learned the basics of Git and I am familiar with the commands, but I can`t figure out how to migrate the project, although reading several questions on Stackoverflow. I want to maintain a dev version accessible at dev.foo.com. Should I do it that way:
git init
, git add .
and git commit
. git pull file:////var/www/stable .
Once that is done, I should be able to work in my dev environment and have branches in the dev repo, but how will I push the changes to the stable version? Is there a better way to organize that process?
Upvotes: 0
Views: 304
Reputation: 2883
You may create a bare repo that you push your work to and fetch changes to the stable directory. Make a clone in the stable directory and another clone where you do the actual work.
In a directory where you keep the bare repo
git init --bare
In the stable directory
git init
git add .
git commit -m "first commit"
git remote add origin <path to bare repo>
git push origin master
Create a clone where you do the work
git clone <path to bare repo> dev
cd dev
git fetch
...do some work ...
git add .
git commit -m "fix for...."
git push origin master
When you are sattisfied with the your work, go back to the stable directory
git pull origin
This is one way of doing this, you may need to change this workflow so suite your needs.
Upvotes: 1