git命令行&github工作流总结
- git是代码版本控制器,github是远程代码托管中心。
 - git操作三个区,工作区,暂存区,版本库
 - github操作四个区,工作区,暂存区,版本库,远程库
 
git工作流
查看:
本地分支:git branch
远程分支:git branch -r
推送代码:
git push origin localBranch
拉取代码:
git pull origin remoteBranch
等价于
git fetch origin remoteBranch
git merge orign/remoteBranch
删除:
本地分支:git branch -d localBranch
远程分支:git push origin -d remoteBranch
拉取远程分支到本地:
git fetch
git checkout -b localBranch origin/remoteBranch
或
git fetch origin remoteBranch:localBranch
git checkout localBranch
git branch --set-upstream-to=origin/remoteBranch localBranch
新建本地分支同步到远程:
git branch localBranch
git push -u origin localBranch
或
git checkout localBranch
git push origin localBranch:remoteBranch
github工作流:
多个协同开发
个人协同开发,团队协同开发。
代码review:
如提交到远程的remoteBranch合并到本地的dev_common,同github提交PR的过程,git命令:
git fetch origin
git checkout -b localBranch orign/remoteBranch
git merge dev_common
create a new repository:
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin git@github.com:chinahub/yii-open-good-project.git
git push -u origin master
push an existing repository:
git remote add origin git@github.com:chinahub/yii-open-good-project.git
git branch -M master
git push -u origin master
git tag -a v1 -m "第一版"
git push origin --tags
其它说明:
查看git帮助:git --help,查看某个命令帮助:git branch -h
origin 是默认的远程版本库的别名,在.git/config中有相应的设置。
                    
                
                
            
        
浙公网安备 33010602011771号