美文网首页
常用GIT 命令

常用GIT 命令

作者: 不会弹钢琴de大叔 | 来源:发表于2024-03-03 10:25 被阅读0次

自我总结的,开发中常用的GIT命令,有需要的伙伴可以看一下

  1. 拉取
git pull
git pull origin master
git pull origin HEAD
  1. 推送
git push
git push origin master 
git push origin HEAD
// gerrit
git push origin HEAD:refs/for/devlop
  1. 提交
git  commit -m 'commit message'
//追加提交,上次commit信息有误,通过此命令更改
git commit --amend
  1. 查看分支
git branch -a
git branch -v
  1. 检出分支/切换分支
git checkout dev
  1. 创建分支
git branch dev
  1. 将新分支推送到远程
git push --set-upstream origin dev
  1. 将分支还原
//不保留修改内容
git reset --h commitID
//保留修改内容
git reset --f commitID
  1. 暂存
git stash save 'xxxx'
  1. 暂存列表
git stash list
  1. 恢复暂存
git stash apply stash@{0}
  1. 删除暂存列表数据
git stash drop stash@{0}
  1. 分支状态
git status
  1. 查看提交日志
git log
git log --oneline
git log -3
  1. 查看变更文件内容对比
git diff xxx
  1. 查看提交日志详细
git show commitID
  1. 将提交记录从a分支同步到b分支
git cherry-pick commitId
  1. 查看两个分支log区别
git log master...dev --oneline
  1. 合并多个commit内容(进阶)rebase
当前分支提交记录,我现在需要将01 02 03 合并为一次提交
ccb8292 (HEAD -> master) 03
28c69c6 02
2c747c3 01
05a8310 (origin/master, origin/dev, origin/HEAD, dev) xxx
...
git rebase -i 05a8310
  • 进入编辑界面


    image.png
  • 将02 03提交记录的 pick改为s 01 提交记录不变 保持pick


    image.png
  • CTRL+o 写入 CTRL+w 保存 CTRL+x退出


    image.png
  • 修改提交信息 CTRL+o 写入 CTRL+w 保存 CTRL+x退出


    image.png
此时提交记录已变更
5907631 (HEAD -> master) 01-new
05a8310 (origin/master, origin/dev, origin/HEAD, dev) xxx

相关文章

  • Git 常用命令详解

    @[TOC](Git 常用命令详解) 1. Git 常用命令 1.1 常用git 命令图表汇总 1.2 配置个人信...

  • git相关教程汇总

    1. git常用命令 git常用命令总结git常用命令讲解 2. git教程相关网站 廖雪峰的git教程猴子都能懂...

  • GIT 版本管理 常用命令

    Git 常用命令流程图 Git常用操作命令: 初始化创建:$ git init //检出仓库:$ git clon...

  • git命令整理

    git常用命令 GIT常用命令备忘:http://stormzhang.com/git/2014/01/27/gi...

  • GIt 操作补充

    常用的git操作命令 常用的git操作命令已经能够满足日常的工作需求 现补充一些高级命令 git branch -...

  • Git

    常用Git命令

  • Git 日常知识

    git常用命令行命令: 1、git 中本地库常用的命令: 本地库的初始化:git init 本地库分支查询:git...

  • Git 常用命令及应用这一篇就够了(新手向)

    1. git 常用命令 1.1 常用命令 1.2 git remote 管理远程仓库 1.3 git r...

  • git操作

    Git原理 Git常用命令

  • GIT 常用命令总结

    GIT 常用命令总结 GIT 初始化命令 命令描述git init初始化本地 git 仓库git config -...

网友评论

      本文标题:常用GIT 命令

      本文链接:https://www.haomeiwen.com/subject/upukzdtx.html