git 常用操作

  • git status  查看状态, 当前分支等信息
  • git checkout [dev] 切换分支
  • git checkout -- filepath+filename  还原文件更改  git checkout -- ./ 还原所有
  • git checkout -b test 创建并切换到新分支
  • git pull ,  git pull origin dev  拉取 / 拉取指定分支
  • git commit -m '备注' 提交本地更改
  • git push / git push origin dev /推送到远程分支 / 指定分支
  • git reset –hard commit-id 还原到指定的 commit , 撤销未Push的commit,  不加commit-id 还原到最新的commit
  • git reset commit-id  撤销commit 但是不对代码撤销, 可随时再进行 git commit
  • git cherry-pick commit-id 摘取一个commit 到当前分支
  • git merge dev 合并指定分支到当前分支
  • git stash 保存当前分支的更改, 但是不提交, 可恢复
  • git stash pop 恢复最新的一次stash
  • git stash list 查看stash 列表
  • git stash drop id 删除stash
posted @ 2018-09-06 10:50  醉丶春风  Views(83)  Comments(0)    收藏  举报