[Git]3. branch, checkout, clone

/**
    Collaborating
*/

$ git clone https://github.com/codeschool/git-real.git                          //copy repo to your local
    Cloning into 'git-real'


$ git clone https://github.com/codeschool/git-real.git  answer-demo             //copy repo to your local and rename this

//check the remote list
$ git romote -v

/**
    Branching out
*/
$ git branch cat                                                                //start a new timeline call cat
$ git branch                                                                    //check which timeline we are using
                                                                                //at this time we are still in master
$ git checkout cat                                                                //switch to branch (timeline) cat
$ git checkout master 

//create a new file and put stuff into here
$ echo "Schrodinger" > cat.txt
$ git add cat.txt
$ git commit -m "Create quantum cat."
    Those code will be added to cat branch not master branch.
    
//If you go back to the master timeline
$ git checkout master
$ ls
    we can see there is not cat.txt
$ git log
    we can see no commit cat log is there

    In master timeline
$ git merge cat                                                                //The cat branch will be merged into master

/*When you are done with a branch, you can safely remove it*/
$ git branch -d cat


/**
    NON-FAT-FORWARD
*/
$ git checkout -b admin                                                           //created and checkout branch

Vi Commands:
j : down       k : up      ESC : leave mode      :wq : save & quit
h : left       l : right     i : insert mode     :q! cancel & quit
相關文章
相關標籤/搜索