20130227

CodeIgniter, Git and friends

Git:
http://git-scm.com/book/en/Getting-Started-Git-Basics
Useful commands:
git help
git config --list
git config --global push.default current
git init   #creating repo for existing project
git add filenamepattern   #stage file
git add -i #interactive staging
git commit -m "initial project version"
git clone [url] [dir]   #clone repository to contribute - dir optional
git status
git diff   #see unstaged changes
git diff --staged   #see staged changes to be commited
git diff --cached   #same as previous - old syntax
git commit   #commit without inline comment - will bring up editor for notes
git commit -a -m 'added new benchmarks'   #commit all tracked filed without need to stage them
----
removing files:
rm filetoremove.ext   #removes physical file
git rm filetoremove.ext   #adds removal to staging
git rm -f filetoremove.ext   #force remove file if it was previously already staged
git rm --cached forgottogitignore.ext   #remove file from tracked files, 
                                        #but keep it in working dir (e.g. for forgotten .gitignore)
git mv file_from file_to   #rename/move file (same as "mv f1 f2/git rm f1/git add f2" operations)
git log   #show all project history
git log -p -2   #show last 2 commits
git log --stat   #summary
git log --pretty=oneline   #display commit comments in one line
git log --pretty=format:"%h - %an, %ar : %s"   #custom format of history overview
git commit --amend   #replace previous commit with sum of previous and current staged files
git reset HEAD filetounstage.ext  #unstage a file accidentally staged
git checkout -- modifiedfile.ext   #replace modified file with current repository version!

git clone git://github.com/schacon/ticgit.git
cd ticgit
git remote   #should say "origin"
git remote -v   #should show what the remote shortnames stand for
   #usually you can pull from any url, bur push only to ssh urls
git remote add [shortname] [url]   #add a remote with certain shortname and url
git fetch [shortname]   #get data from remote about branches
git fetch origin   #fetches any new work that has been pushed to that server
   #note: this will not automatically merge changes with my changes
git pull   #usually - fetches data from the server you originally cloned from 
   #and automatically tries to merge it into the code you’re currently working on
git push [remote-name] [branch-name]   
git push origin master   #push your master branch to your origin server
   #note: will not work if someone has pushed before you
git remote show [remote-name]   #show info on remote status

git tag
git tag -a v1.4 -m 'my version 1.4'
git show v1.4

#Branching means you diverge from the main line of development 
#and continue to do work without messing with that main line
#default branch is master, and HEAD points to master by default
git branch testing   #adds a new branch, but you need to switch to it 
   #if you want to work on it
git checkout testing   #moves HEAD pointer to branch testing
git commit -a -m 'made a change'   #modify something, and do changes to new branch
   #now master and testing are different
git checkout master   #reverts your working directory to master branch

#scenario
git checkout -b hotfix   #creates an adhoc branch "hotfix", you do changes
git commit -a -m 'fixed the broken email address'   #commit it
git checkout master   #load the master version
git merge hotfix   #merge hotfix to master
git branch -d hotfix   #delete hotfix branch

git status   #see unmerged files after conflict
git add [file]   #after resolving conflicts, add resolved files
git mergetool   #opens up one of the merge tools (not needed if add used)
git commit   #to commit resolved issue

git branch -v   #will show which branch you are on
git branch --merged   #will show branches merged to your current one
   #branches without * in front are usually fine to delete
git branch --no-merged   #show branches not merged to current one
   #careful not to lose something that someone has worked on

$ git stash
...
$ git stash pop

$ git whatchanged --since="1 day ago" -p FILENAME

.gitignore file sample:
# a comment - this is ignored
*.a       # no .a files
!lib.a    # but do track lib.a, even though you're ignoring .a files above
/TODO     # only ignore the root TODO file, not subdir/TODO
build/    # ignore all files in the build/ directory
doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt

Alot more on viewing git logs: http://git-scm.com/book/en/Git-Basics-Viewing-the-Commit-History
Git autocomplete
Continue reading: http://git-scm.com/book/en/Git-Branching-Remote-Branches
CodeIgniter:
http://ellislab.com/codeigniter/user-guide/
http://ellislab.com/codeigniter/user-guide/general/styleguide.html
http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-day-4-newsletter-signup/
http://www.farinspace.com/codeigniter-conditional-required-field/
Database refactoring: http://databaserefactoring.com/
Database models: http://www.databaseanswers.org/data_models/index.htm
Charting: http://www.highcharts.com/demo/ and http://stackoverflow.com/questions/119969/javascript-chart-library
http://wiki.nginx.org/Codeigniter http://kbeezie.com/nginx-and-codeigniter/ http://www.farinspace.com/codeigniter-nginx-rewrite-rules/