git学习

学习git的基本命令,下面是一些经常会遇到的场景。

  • 创建一个git目录,新增文件,查看状态,提交文件
    • git init
    • git add .
    • git status -s
    • git commit -m "sss"
  • 合并一次提交
    • git commit --amend --no-edit
  • 查看修改记录
    • git log --online -graph
    • git reflog
  • 对比版本
    • git diff
  • 整个版本回退
    • git reset
    • git reset HEAD^
    • git reset HEAD~100
    • git reset 234ert6
  • 单个文件回退
    • git checkout  234ert6 -- filename
  • 创建分支,查看分支
    • git branch  mybranch
    • git branch
  • 切换分支
    • git checkout mybranch
    • git checkout -b mybranch
  • 删除分支
    • git branch -d mybranch
  • 合并分支(merge合并到当前分支)
    • git merge mybranch
    • git merge --no-ff -m "keep merge info" mybranch
    • git rebase master
  • 合并分支(rebase)基本master分支rebase
    • git rebase master
    • git rebase --continue
  • 缓存
    • git stash
    • git stash pop
原文地址:https://www.cnblogs.com/morninglight/p/7840874.html