> 技术文档 > Git 指令大全(全干货版)_git指令

Git 指令大全(全干货版)_git指令


🔧 基础操作

# 初始化仓库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 startgit 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)%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 全平台兼容。

深圳旅游景点大全