Git 常用操作命令
Git 常用操作
克隆仓库
# 克隆仓库
git clone <url>
拉取
# 拉取
git pull
推送提交
# 推送提交
git push
暂存修改
# 暂存
git stash
# 列出所有的暂存状态
git stash list
# 从暂存区之中进行恢复
## 方式1 先恢复,而后再删除暂存
git stash apply
git stash drop
## 方式2 恢复的同时也将stash内容删除
git stash pop
Git 分支操作
创建分支
# 创建指定名称的分支
git branch <branch_name>
# 创建并切换到指定分支
git checkout -b <branch_name>
查看分支
# 查看所有分支
git branch -a
# 查看当前使用分支
git branch
切换分支
# 切换到指定分支
git checkout <branch_name>
分支合并
# 将指定分支合并到当前分支(例如在主分支合并开发分支)
git merge <branch_name>
删除分支
# 删除一个干净的分支(即相对当前分支而言该分支没有新的提交记录)
git branch -d <branch_name>
# 强制删除一个分支,该分支有没有合并到当前分支的提交记录
git branch -D <branch_name>
分支恢复
# 先查找该分支指向的commit id
git reflog
# 根据指定commit创建新分支
git branch <branch_name> <hash_val>
重命名分支
# 指定分支重命名
git branch -m <branch_name> <newname>
参考资料
https://www.jianshu.com/p/2e162b544878
http://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA%E4%B8%8E%E5%90%88%E5%B9%B6
Git学习推荐网站
基础学习
https://backlog.com/git-tutorial/cn/intro/intro1_1.html
闯关式学习
https://learngitbranching.js.org/?locale=zh_CN
Github相关学习
https://docs.github.com/cn/actions/quickstart
https://github.phodal.com/#/chapter/Github%E6%BC%AB%E6%B8%B8%E6%8C%87%E5%8D%97