[Git]2. reset, checkout, origin, remote, pull, push

/**
    
*/

$ git diff                                                        //view the differences, to see what you have changed.
                                                                //onces you have commit the files, you run this again
                                                                //you will see empty
                                                                //but if you do want to see what is the difference
$ git diff --staged                                                //View staged differences

/*Unstaging files*/
$ git reset HEAD README.txt                                        //unstage teh file, HEAD refers to the top file in the MASTER timeline

/*Discard changes*/
$ git checkout -- README.txt index.html                         //discard changes in index.html and readme.txt
$ git status
    nothing to commit (working directory clean)
    
/*SKIP Staging and commit*/
$ git commit -a -m "This both add to stage then commit files"   //Add changes form all tracked files

/*Undoing a commit*/
$ git reset --soft HEAD^                                            //--soft: Rest into staging
                                                                //HEAD^ : Move to commit before 'HEAD'
/*Adding to a commit*/    
$ git add todo.txt
$ git commit --amend -m "Modify readme & add todo.txt."         //whatever has been staged is added to last, means you don't create a new commit, just work on the last one
$ git reset --hard HEAD^                                          //undo last commit and all changes
$ git reset -- hard HEAD^^                                        //undo last 2 comments and all changes


/**HOW TO SHARE**/
$ git remote add origin https://github.com/zhentiw/Question.git
//origin: our name for this remote
//https://github.com/Gregg/git-real.git: address

/*To remove remotes*/
$ git remote rm <name>

/**/

/*Show remote repositories*/
$ git remote -v

/**PUSHING TO REMOTE**/
$ git push -u origin master                                     //master is local branch to push
                                                                //-u : menas next time when you want to push the file, u can just use "git push"

/**PULLING from remote**/
$ git pull                                                      //get changes by others

 

posted @ 2014-08-15 21:50  Zhentiw  阅读(397)  评论(0)    收藏  举报