美文网首页
Git 常用指令记录

Git 常用指令记录

作者: 惟吾德馨_慧 | 来源:发表于2022-05-20 16:24 被阅读0次

1.配置用户名和邮箱
git config --global user.name "用户名" 配置或修改用户名
git config --global user.emal "836965140@qq.com" 配置或修改邮箱
eg:git config --global user.name 'ww0062167'
git config --global user.email 'wuhuihui3@hihonor.com'

git config --list 查看配置项
git config user.name 查看用户名
git help 查看git帮助
git config --global --replace-all user.name “你的用户名” 修改你的用户名
git config --global --replace-all user.email “你的邮箱”  修改你的邮箱

2.管理git项目
git init 生成.git文件 ,被git管理
git init [name] 如果加上文件名 则是先创建一个文件名,然后在生成.git文件
git add [filename] 添加文件被追踪,添加到暂存区
git add . 添加所有文件被追踪,添加到暂存区
git status 查看文件的状态
git commit -m “描述”
git commit -am 相当于 add. + -m

3.log追踪
git log 相当于你的提交日志
git log -p -2 最近两次提交内容的不同
git log --author
git log --oneline 简化版的git log,只显示一行。
git log --graph 查看版本线图
git log --pretty=format 打印出格式化的日志

4.代码回退
方式1、使用 git checkout 撤销本地修改
git checkout . # 撤销对所有已修改但未提交的文件的修改,但不包括新增的文件
git checkout [filename] # 撤销对指定文件的修改,[filename]为文件名
以上方式不适用于已经 add / commit 的文件,应使用下面提到的方式。
方式二、使用 git reset 回退项目版本
git reset --hard [commit-hashcode] # [commit-hashcode]是某个 commit 的哈希值,可以用 git log 查看
例如:git reset --hard 97206e0f1d0e153e738f3344a935f5ce28df6635
可以回退到任意已经提交过的版本。已 add / commit 但未 push 的文件也适用

5.git分支管理:
master:git默认主分支(这里不作操作)。
stable:稳定分支,替代master,主要用来版本发布。
develop:日常开发分支,该分支正常保存了开发的最新代码。
feature:具体的功能开发分支,只与 develop 分支交互。
release:release 分支可以认为是 stable分支的未测试版。比如说某一期的功能全部开发完成,那么就将 develop 分支合并到 release分支,测试没有问题并且到了发布日期就合并到 stable分支,进行发布。
bugfix:线上 bug 修复分支。

创建分支:$ git branch testing  //创建了一个testing分支
git log 命令查看各个分支当前所指的对象:$ git log --oneline --decorate
切换分支:$ git checkout testing   //切换到新创建的 testing 分支
新建分支并同时切换到该分支:$ git checkout -b issue10  //新建分支issue10并切换到该分支
删除分支:$ git branch -d issue10  //删除分支issue10
查看分支列表:$ git branch
查看每一个分支的最后一次提交:$ git branch -v
查看设置的所有跟踪分支:$ git branch -vv
输出你的提交历史、各个分支的指向以及项目的分支分叉情况:$ git log –oneline –decorate –graph –all
合并分支:$ git merge issue10 //需要切换到master分支后,才可合并其他分支

每天进步一点点。。。(2022-05-20)

相关文章

  • Git常用指令记录

    git init 这个目录变成Git可以管理的仓库 git status 查看当前仓库状态 git diff re...

  • Git 常用指令记录

    标准指令以及功能 指令功能git clone 仓库链接从远端仓库克隆工程git init初始化仓库git chec...

  • Git 常用指令记录

    1.配置用户名和邮箱git config --global user.name "用户名" 配置或修改用户名git...

  • Git的使用

    star 记录一下Git的使用,逐步用到了,一步一步更新 GIT 常用指令记录 START 记录一下,GIt的使用...

  • git远程仓库关联

    一.GitHub常用指令 git的基本使用指令:git init ...

  • git使用率最高的指令

    git常用指令

  • Git Flow 最佳实践笔记

    阅读了Vincent Driessen的Git最佳实践模式,这里对日常操作的指令加以总结记录。 常用指令 Feat...

  • 组件化(第一篇)

    组件化 git 常用操作指令 cocoapods的基本使用 cocoapods本地私有库 一、git 常用操作指令...

  • git常用命令(三)

    git常用指令(一)[https://www.jianshu.com/p/3b80461fb59b]git常用指令...

  • git常用指令(一)

    git常用指令(二)[https://www.jianshu.com/p/348409e59f7c]git常用指令...

网友评论

      本文标题:Git 常用指令记录

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