iOS学习

git 命令的日常用法

2017-10-21  本文已影响0人  皮皮强

官方在线书籍:

https://git-scm.com/book/en/v2

常用命令:

git status 查看当前分支状态

git log 查看当前分支commit历史, 退出查看按q

git branch查看所有本地自己的分支

git branch -a 查看所有本地自己的分支,和本地仓库的所有分支

git diff 比较staged &unstaged代码

git checkout branchname 切换分支

git fetch 拉取所有远程分支

git pull 拉取当前分支&合并当前分支

git branch branchname 从当前分支新建一个分支

git branch -D branchname 删除分支,删除的时候不能在当前分支,可以先checkout到其他分支,再删除branchname

git checkout -b branchname 从当前分支新建一个分支,并切换到新分支

git checkout -b branchname sourcebranch/SHA1 从sourcebranch/SHA1新建一个分支,并切换到新分支

git add 加到staging area

git add . 把当前新加修改的文件,全部加到staging area

git commit -m "comment" 加到本地仓库

git push 本地仓库推送到远程仓库

git push -u origin brnanname  本地仓库推送到远程仓库,同时本地远程分支连接

git merge branchname 把branchname合并到当前分支

如果合并有冲突,手动解决冲突,或者用git mergetool解决冲突,再合并

git cherry-pick 0bd0c417093fb795afcfb6170b90093e2b8b193f

git mergetool --tool=opendiff

git mergetool --tool-help

git merge release-4.0

上一篇 下一篇

猜你喜欢

热点阅读