Git

From Wiki2

git

the work flow

The idea is to have production code on server and then a copy of that code locally. That copy has a branch that you can try fixes in. When the fixes are working well locally you can try them on the server from the same branch. When they are ready to go live you can merge the branch with the master locally, push it to github and fetch from github to the server where you merge the github master into the server master.

the setup

by cloning from github

Started by cloning code on your local machine(which creates a remote named 'origin')

$ git clone git@github.com:mckennatim/OBsoup.git

Then create a branch for putting new features:

$ git checkout -b loco
Switched to a new branch 'loco'
staring on a local drive

To make your current directory a Git repository we simply run init.

git init
git add .
git commit -m "initial commit"

Create a new repository on GitHub. It will tell you something like the following

 cd existing_git_repo
 git remote add origin git@github.com:mckennatim/food2buy.git
 git push -u origin master

Enter passphrase for key '/c/Users/tim/.ssh/id_rsa': nj.

remove sensitive data
tekkub@iSenberg ~/tmp/github-gem master
$ echo "Rakefile" >> .gitignore

tekkub@iSenberg ~/tmp/github-gem master*
$ git add .gitignore

tekkub@iSenberg ~/tmp/github-gem master+
$ git commit -m "Add Rakefile to .gitignore"
[master 051452f] Add Rakefile to .gitignore
 1 files changed, 1 insertions(+), 0 deletions(-)

normal test process

locally

do some editing locally on a (loco)branch and test locally then add. and commit locally

(loco)$git add .
(loco)$git commit -m "my local edits"

push that branch to github

(loco)$git push origin loco
server

try the local changes by fetching the github origin then fast-forward the server branch by

(loco)$git fetch origin 
(loco)$git merge origin/loco


Now the server is running from the loco branch. If you want it running from the older master code

(loco)$git checkout master
(master)$

once new code is tested on server from (loco)

Decided the protocal is to start merging branch into master locally then pushing it to GitHub then fetching from Github to server and merging there.

locally

OK so the branch can merge into master locally

(local)$ git checkout master
(master)$ git merge loco

Then push it to github

(master)$ git push
server

Get the merged master from github and mege it with the servers master

(master)$git fetch origin 
(master)$git merge origin/master