Yu-Chieh’s Blog (Y.C. Chang)

Ruby on Rails / Rubygems / FullStack / Git / Mac notes.

Git Flow Usage

git-flow usage notes

  • install git-flow on Mac
1
$ brew install git-flow # Done
  • usage how-to (for feature)
1
2
3
4
5
6
7
$ git flow init # under project folder, git-flow would ask few questions, using the default value is recommended. 
$ git flow feature start MY_FEATURE # XXX is branch name
# add some files or do something ...
$ git add .
$ git commmit -am 'do something ...'
$ git flow feature publish MY_FEATURE # push to remote repo
$ git flow feature finish MY_FEATURE
  • usage how-to 2 (for release)
1
2
3
4
5
$ git flow release start RELEASE [BASE]
# e.g. git flow release start Version_1.0
$ git add .
$ git commit -am 'do something ...'
$ git flow release finish RELEASE

[recommand reference]

http://danielkummer.github.io/git-flow-cheatsheet/
http://fireqqtw.logdown.com/posts/206951-git-flow-notes

Git Usage Notes

Install git via homebrew

1
$ brew install git # If we want to use gitk (git GUI), this way is very convinient. (however, I think SourceTree is better.)

Git work processes

  • sign up a github account
  • create a repos (repository) with a “name”
  • then git it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# rails project
$ rails new app
$ cd app
$ git init
$ git add .
$ git commit -m 'first commit'

$ git checkout -b branch_name
$ git branch # list branches in the project

# do some changes under this branch ...  

$ git add .
$ git commit -am 'some thing in this brach'

# more about `git commit` 
$ git commit -am 'xxxx' # == git add . + git commit -m 'xxxx'
$ git commit --amend # reword commit message

# go back to master and merge it

$ git checkout master
$ git merge branch_name

# push to github 

$ git remote add origin repos_git_ssh_url
$ git push --all # both master and branches
$ git push origin master # you also can push master to remote only

# reset or revert to HEAD version (HEAD refers to latest commit stage)

$ git reset HEAD --hard # --hard is dangerous (delete unstaged files)
$ git reset HEAD --soft # --soft will go back and keep files staged 
$ git reset HEAD # will go back without tracking unstaged files
$ git revert HEAD # make HEAD stage as new stage

# reset one file

$ git checkout -- <file>

# conflick of rebase (merge is the same)

$ git rebase master # under second branch
# conflick ...
# modify conflick <file>
# then 
$ git add <file>
$ git rebase --continue
# done.

# To remove untracked files / directories do:

$ git clean -fdx
# -f - force
# -d - directories too
# -x - remove ignored files too ( don't use this if you don't want to remove ignored files)

great reference

http://blog.yorkxin.org/posts/2011/07/29/git-rebase
http://blog.gogojimmy.net/2012/02/29/git-scenario/

Learning Notes for 12in12 Week 1

CREATE OUR NEW RAILS APPLICATION

1
2
3
4
5
$ rails new reddit
$ cd reddit
$ git init
$ git add .
$ git commit -m "reddit init"

LINK SUBMISSIONS

1
2
3
4
5
6
7
$ git checkout -b link_scaffold
$ rails g scaffold link title:string url:string
$ rake db:migrate
$ git add .
$ git commit -m "Generate Links Scafffold"
$ git checkout master
$ git merge link_scaffold

Set Up Octopress on 2nd Mac for the Same Blog

在另外一台Mac上安裝octopress編輯環境, 可對應編輯同一個github的blog

  1. copy prikey from your master mac to your 2nd mac device and put it under ~/.ssh folder
  2. clone your repository to second device
1
$ git clone https://github.com/xxx/xxx.github.io.git
  1. setup your 2nd mac device
1
2
3
4
5
6
7
$ cd xxx
$ bundle install #install required gems
$ ssh -T git@github.com # for testing connection to github
$ rake setup_github_pages # this is important for create _deploy folder in 2nd mac device
$ rake new_post["xxxx"] 
$ rake generate
$ rake deploy # it's done while no error message here.
  1. git between two mac device
1
2
3
4
$ git pull origin source  # git pull before push every time!
$ git add .
$ git commit -m 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam'
$ git push origin source

Done.

How to Install Ruby and Rails on Windows

在Windows上安裝ruby on rails開發環境

Easy and the quickest way.

install RailsInstaller

  1. Download it (version 3.0.0 and above are recommend) from http://railsinstaller.org
  2. install it (just click next and next steps, then done.).
  3. open “Git bash” console and run the following command.
1
$ curl http://installrails.com/update_rubygems.rb | ruby
  1. in “Git Bash” console run
1
$ gem update --system

about bundle errors (can not fetch gems from rubygems default source): how do we solve it?

  • Open and edit Gemfile after rails new app
  • Change the => source ‘https://rubygems.org’ to => source ‘http://rubygems.org
  • Add gem ‘coffee-script-source’, ‘1.8.0’ in Gemfile and run bundle update # original 1.9.1 wouldn’t work on windows platform.
  • done.

How to Install Ruby and Rails on Mac

在Mac上安裝ruby on rails開發環境

1. install rvm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#comment
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby  
#(if error message shown -> rvm reinstall 2.1.3 --disable-binary)  
  
#modify .zshrc .bash_profile and relaunch terminal
$ echo progress-bar >> ~/.curlrc  
$ echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile  
$ echo "gem: --no-document" >> ~/.gemrc  
  
#test rvm ready or not  
$ type rvm | head -n 1  
$ rvm list known  
$ rvm install x.x  
$ rvm use 2.1 (rvm use 2.1 --default)

2. install bundler and rails

1
2
3
$ gem update --system #更新gem library
$ gem install bundler #安裝bundler
$ gem install rails --no-ri --no-rdoc #安裝rails
  • Done!!

How to Install Octopress on Github

在Github上使用octopress建構blog

1. on mac

1
2
3
$ cd ~/.ssh
$ ssh-keygen -t rsa -C "xxx@xxx.xxx.xx"
$ pbcopy < ~/.ssh/id_rsa.pub #copy pubkey to clipboard

2. on Github

github 申請帳號 (e.g. xxxx)
github 建立 xxxx.github.io 的repository
github 上傳ssh key