G

Git命令学习记录

轻松学习 技术 2023-08-14

常用命令

  • 初始化Git init
  • 设置签名 git config user.name "cemon"
  • 设置签名邮箱git config user.email "cemon_liu@126.com"
  • 设置全局 git config --global
  • 查看config 签名 git config --list
  • 查看状态git status
  • 提交 git add 文件名 git add .添加所有目录文件
  • commit 命令 git commit -m "更新内容"

    • git commit -am可以跳过add命令 直接提交
  • 回退版本 git reset HEAD^ 几个^ 就是退几个版本
  • 移动或者重命名文件 git mv README README.MD
  • 查看日志文件 git log
  • 查看指定文件修改记录 git blame file

远程操作命令

  • 生成SSH Key $ ssh-keygen -t rsa -C "youremail@example.com" 打开 id_rsa.pub,复制里面的 key
  • 查看远程连接 git remote -v
  • 添加远程仓库 git remote add origin [url]
  • 提交代码到远程 git push -u origin master
  • 取远程代码 并合并 git pull = git fetch git merge

分支的操作

  • 创建分支 git branch newbranch
  • 查看各分支状况git log --oneline --decorate
  • 查看分支交叉历史git log --oneline --decorate --graph --all
  • 切换分支 git checkout testing
  • 合并分支 git checkout master git merge testing
  • 删除分支 git branch -d testing
  • 删除服务器分支 `git push origin --delete serve
PREV
batch命令学习
NEXT
Hexo github action部署修改配置

评论(0)

发布评论