转载于:http://blog.youkuaiyun.com/csfreebird/article/details/7992164 与 http://blog.youkuaiyun.com/u010897406/article/details/50427191
1.创建分支
git checkout -b feature_name
git中推荐为了某个新的功能创建feature branch,完成后再将其合并到master中。
然后就可以用git branch来查看所有分支。
2.切换分支
如果有了多个branch, 就可以用checkout切换到某个branch。用法很简单:
git checkout branchname
该命令修改了HEAD文件内容。
3.用staging的文件覆盖工作区的文件
reset用已经提交的文件的某个版本覆盖staging中的同名文件
而checkout又提供了一种更常用的功能。
先添加一个文件,并加入内容yy
再修改文件内容,然后用checkout方法撤销修改
上面的命令如果加上参数branch的话,功能就有所增强
git checkout branchname -- filePath
用branchname中的文件替换staging和working area中的同名文件。
4.查看分支
检出仓库: $ git clone git://github.com/jquery/jquery.git
查看远程仓库:$ git remote -v
添加远程仓库:$ git remote add [name] [url]
删除远程仓库:$ git remote rm [name]
修改远程仓库:$ git remote set-url --push [name] [newUrl]
拉取远程仓库:$ git pull [remoteName] [localBranchName]
推送远程仓库:$ git push [remoteName] [localBranchName]