git add . //添加到暂存盘 git commit -m ‘备注’//提交到本地仓库 git push //提交到远程仓库
fetch更新本地仓库两种方式:
//方法一 $ git fetch origin master //从远程的origin仓库的master分支下载代码到本地的origin master $ git log -p master.. origin/master//比较本地的仓库和远程参考的区别 $ git merge origin/master//把远程下载下来的代码合并到本地仓库,远程的和本地的合并 //方法二 $ git fetch origin master:temp //从远程的origin仓库的master分支下载到本地并新建一个分支temp $ git diff temp//比较master分支和temp分支的不同 $ git merge temp//合并temp分支到master分支 $ git branch -d temp//删除temp
Git鼓励大量使用分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>