4
头图

🔧 基础操作

# 初始化仓库
git init

# 克隆远程仓库
git clone <repo_url>

# 查看当前状态
git status

# 添加全部修改到暂存区
git add .

# 提交到本地仓库
git commit -m "提交说明"

# 查看提交历史(精简版)
git log --oneline

# 查看文件修改差异
git diff

🌿 分支管理

# 创建新分支
git branch <branch_name>

# 切换分支
git checkout <branch_name>

# 创建并切换分支
git checkout -b <new_branch>

# 合并分支到当前分支
git merge <branch_name>

# 删除本地分支
git branch -d <branch_name>

# 强制删除未合并分支
git branch -D <branch_name>

# 查看所有分支(含远程)
git branch -a

🚀 远程仓库操作

# 添加远程仓库
git remote add <remote_name> <repo_url>

# 推送本地分支到远程
git push -u <remote_name> <branch_name>

# 强制推送(慎用!)
git push -f

# 拉取远程更新
git pull <remote_name> <branch_name>

# 获取远程分支但不合并
git fetch

# 删除远程分支
git push <remote_name> --delete <branch_name>

⏪ 撤销操作

# 撤销工作区修改
git checkout -- <file>

# 撤销暂存区文件
git reset HEAD <file>

# 修改最后一次提交
git commit --amend

# 回退到指定提交(保留修改)
git reset --soft <commit_id>

# 彻底回退到指定提交(慎用!)
git reset --hard <commit_id>

# 恢复误删的文件
git checkout <commit_id> -- <file_path>

🔍 日志与查询

# 图形化提交历史
git log --graph --all

# 按作者搜索提交
git log --author="name"

# 搜索提交内容
git log -S "keyword"

# 显示某文件的修改历史
git blame <file>

🔗 标签管理

# 创建标签
git tag <tag_name>

# 创建带注释标签
git tag -a v1.0 -m "版本说明"

# 推送标签到远程
git push --tags

# 删除本地标签
git tag -d <tag_name>

# 删除远程标签
git push origin :refs/tags/<tag_name>

🧩 高级操作

# 贮藏当前修改
git stash

# 应用最近贮藏
git stash pop

# 交互式变基(修改最近3次提交)
git rebase -i HEAD~3

# 二分法查找问题提交
git bisect start
git bisect bad         # 标记当前为错误提交
git bisect good <id>   # 标记已知正常提交

# 清理未跟踪文件
git clean -fd

⚙️ 配置相关

# 全局用户名配置
git config --global user.name "Your Name"

# 全局邮箱配置
git config --global user.email "email@example.com"

# 查看所有配置
git config --list

# 设置别名(例如简化log)
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"

📦 子模块管理

# 添加子模块
git submodule add <repo_url> <path>

# 初始化子模块
git submodule init

# 更新子模块
git submodule update

📌 实用技巧

# 忽略文件权限变更
git config core.fileMode false

# 生成.gitignore模板
curl https://gitignore.io/api/<语言/工具>

# 查看仓库大小
git count-objects -vH

# 克隆指定分支(浅克隆)
git clone --branch <branch_name> --depth 1 <repo_url>

注意事项:

  1. --force操作前务必确认影响范围
  2. 重要分支(如main/master)避免直接修改
  3. 推荐使用SSH协议进行远程操作
  4. 定期执行 git gc 优化仓库

dblens数据库客户端[推荐]

https://sourceforge.net/projects/dblens-for-mysql

dblens数据库管理工具(dblens for mysql)
  • 🔧 可视化索引使用分析
  • 📊 AI 索引设计分析
  • 💡 智能索引优化建议
  • 📊 AI 快速设计表、视图、函数、事件、存储过程

    dblens数据库管理工具
  • 🖥 可视化设计:拖拽式表结构设计,ER 关系图自动生成,降低建模门槛。
  • ⚡ 智能 SQL 开发:支持语法高亮、代码补全、执行计划分析,查询效率提升 50%+。
  • 独特优势 全中文支持:界面 / 文档 / 社区全面本土化,降低学习成本。
  • 跨平台适配:Windows/macOS/Linux 全平台兼容。

DBLens
185 声望94 粉丝

DBLens([链接]):高效的数据库管理工具。