当前位置: 首页 > web >正文

Git 命令速查手册

听说用美图可以钓读者?
一、基础操作核心命令
1. 仓库初始化与克隆
命令作用示例
git init创建新仓库git init my-project
git clone克隆远程仓库git clone [https://github.com/user/repo.git](https://github.com/user/repo.git)
git remote add关联远程仓库git remote add origin [https://github.com/user/repo.git](https://github.com/user/repo.git)
2. 文件操作
命令作用示例
git add添加文件到暂存区git add .(添加所有)
git rm删除文件git rm file.txt
git mv重命名文件git mv old.txt new.txt

二、配置管理(含代理)
1. 多层级配置
命令作用示例
git config --global全局配置git config --global user.name "John"
git config --local仓库级配置git config --local core.autocrlf false
git config --list查看配置git config --list --show-origin
2. 代理管理
类型命令示例
HTTP代理git config http.proxygit config --global http.proxy [http://127.0.0.1:7890](http://127.0.0.1:7890)
域名级代理git config http.[url].proxygit config --global http.[https://github.com.proxy ](https://github.com.proxy )socks5://127.0.0.1:1080
清除代理git config --unsetgit config --global --unset http.proxy

三、提交与版本控制
1. 提交操作
命令作用示例
git commit -m标准提交git commit -m "feat: add login"
git commit --amend修改提交git commit --amend --no-edit
git rebase -i交互式变基git rebase -i HEAD\~3
2. 版本追溯
命令作用示例
git log查看历史git log --oneline --graph
git diff对比差异git diff HEAD\~1 HEAD
git blame追踪修改git blame config.ini

四、分支与协作
1. 分支管理
命令作用示例
git branch查看分支git branch -av
git checkout -b创建分支git checkout -b dev
git merge --no-ff保留合并历史git merge dev --no-ff
2. 远程协作
命令作用示例
git push -u推送并关联git push -u origin main
git pull --rebase变基式拉取git pull --rebase
git fetch --prune清理远程分支git fetch --prune

五、高级操作速查
1. 撤销与恢复
命令作用场景
git checkout -- [file]撤销工作区修改未暂存时恢复
git reset --soft撤销提交保留修改git reset HEAD\~1
git reflog找回误删提交git reflog
2. 代理验证方法
操作命令输出验证
检查代理配置git config --get-regexp 'proxy'显示生效代理地址
测试SSH代理ssh -Tv git@github.com查看代理握手日志
流量监控sudo lsof -i :7890 | grep git确认git使用代理端口

 

完结散花。

http://www.xdnf.cn/news/496.html

相关文章:

  • 每日一记:CRT和图论
  • 分布式系统核心原理
  • 【第1-3章】PLC电工电子基础
  • Linux驱动开发--阻塞、非阻塞I/O
  • 【树莓派Pico FreeRTOS】-中断服务与二值信号量
  • STM32 单片机调试过程中的注意事项
  • dns作业
  • 关于Redis中的事务的理解
  • ping: socket: Operation not permitted
  • JAVAEE(网络原理—UDP报头结构)
  • 嵌入式软件--stm32 DAY 2
  • 鼠标移动操作
  • GNU,GDB,GCC,G++是什么?与其他编译器又有什么关系?
  • 4.17--4.19刷题记录(贪心)
  • swagger的简介及使用方法
  • docker基本使用命令
  • Google Agent 2 Agent 协议深度研究报告
  • Java 编译与反编译深度解析
  • Yarn基本介绍
  • 当我使用uview datetime-picker日期事件插件出行Invalid array length异常时
  • stack,queue和priority_queue
  • gis系统中如何提高shp大文件加载效率
  • 【Datawhale AI春训营】Java选手初探数据竞赛
  • 3D打印加速产品试制
  • 在RK3588上使用ZLMediaKit
  • rabbitmq 面试题
  • 体积虽小,却很好用
  • WSL+Ubuntu+miniconda环境配置
  • 淘宝淘口令解析 Api接口
  • 定制一款国密浏览器(9):SM4 对称加密算法