东营网站app建设外贸网站建设制作设计案例
2026/4/6 3:40:02 网站建设 项目流程
东营网站app建设,外贸网站建设制作设计案例,photoshop下载手机版,企业网站建设(信科网络)文章目录Git 简介Git vs 其他版本控制系统基础配置基础概念Git 的三个区域文件状态Git 对象类型仓库操作创建仓库仓库信息文件操作添加文件到暂存区提交更改查看差异删除和移动文件分支管理分支基础操作分支管理分支合并远程仓库远程仓库管理推送和拉取跟踪远程分支标签管理创建…文章目录Git 简介Git vs 其他版本控制系统基础配置基础概念Git 的三个区域文件状态Git 对象类型仓库操作创建仓库仓库信息文件操作添加文件到暂存区提交更改查看差异删除和移动文件分支管理分支基础操作分支管理分支合并远程仓库远程仓库管理推送和拉取跟踪远程分支标签管理创建标签标签操作总结Git 简介Git 是一个分布式版本控制系统由 Linus Torvalds 在 2005 年创建。它具有以下特点分布式每个开发者都有完整的代码历史高性能快速的分支创建和合并数据完整性使用 SHA-1 哈希确保数据完整性非线性开发支持复杂的分支和合并策略Git vs 其他版本控制系统特性GitSVNCVS分布式✅❌❌离线工作✅❌❌分支成本低高高合并能力强中弱性能高中低基础配置# 设置用户信息必需gitconfig--globaluser.nameYour Namegitconfig--globaluser.emailyour.emailexample.com# 设置默认编辑器gitconfig--globalcore.editorcode --wait# VS Codegitconfig--globalcore.editorvim# Vimgitconfig--globalcore.editornano# Nano# 设置默认分支名gitconfig--globalinit.defaultBranch main# 设置行尾处理Windows 推荐gitconfig--globalcore.autocrlftrue# 设置行尾处理macOS/Linux 推荐gitconfig--globalcore.autocrlf input# 启用颜色输出gitconfig--globalcolor.ui auto# 设置别名gitconfig--globalalias.st statusgitconfig--globalalias.co checkoutgitconfig--globalalias.br branchgitconfig--globalalias.ci commitgitconfig--globalalias.unstagereset HEAD --gitconfig--globalalias.lastlog -1 HEADgitconfig--globalalias.visual!gitk# 查看配置gitconfig--listgitconfig--global--listgitconfig user.name基础概念Git 的三个区域工作区 (Working Directory) ↓ git add 暂存区 (Staging Area/Index) ↓ git commit 版本库 (Repository)文件状态未跟踪 (Untracked) ──git add──→ 已暂存 (Staged) ↓ git commit 已跟踪 (Tracked) ←──────────────── 已提交 (Committed) ↓ 修改文件 ↑ 已修改 (Modified) ──git add──────────┘Git 对象类型Blob文件内容Tree目录结构Commit提交信息Tag标签引用仓库操作创建仓库# 初始化新仓库gitinitgitinit my-projectgitinit--bare# 创建裸仓库服务器用# 克隆现有仓库gitclone https://github.com/user/repo.gitgitclone https://github.com/user/repo.git my-foldergitclone--depth1https://github.com/user/repo.git# 浅克隆gitclone--branchdevelop https://github.com/user/repo.git# 克隆特定分支仓库信息# 查看仓库状态gitstatusgitstatus-s# 简短格式gitstatus--porcelain# 机器可读格式# 查看提交历史gitloggitlog--oneline# 单行显示gitlog--graph# 图形化显示gitlog--stat# 显示统计信息gitlog--patch# 显示详细差异gitlog-n5# 显示最近 5 次提交gitlog--since2 weeks ago# 时间过滤gitlog--authorJohn# 作者过滤gitlog--grepfix# 提交信息过滤# 查看文件历史gitlog filenamegitlog-pfilename# 显示文件的详细变更历史# 查看分支图gitlog--graph--prettyformat:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset--abbrev-commit文件操作添加文件到暂存区# 添加单个文件gitaddfilename.txt# 添加多个文件gitaddfile1.txt file2.txt# 添加所有文件gitadd.gitadd-Agitadd--all# 添加所有 .txt 文件gitadd*.txt# 交互式添加gitadd-igitadd-p# 部分添加patch 模式# 添加目录gitadddirectory/# 强制添加被忽略的文件gitadd-fignored-file.txt提交更改# 基本提交gitcommit-m提交信息# 详细提交信息gitcommit# 打开编辑器# 跳过暂存区直接提交gitcommit-a-m提交信息gitcommit-am提交信息# 修改最后一次提交gitcommit--amendgitcommit--amend-m新的提交信息gitcommit--amend--no-edit# 不修改提交信息# 空提交用于触发 CI/CDgitcommit --allow-empty-mEmpty commit# 提交时签名gitcommit-S-mSigned commit查看差异# 查看工作区与暂存区的差异gitdiff# 查看暂存区与最后一次提交的差异gitdiff--stagedgitdiff--cached# 查看工作区与最后一次提交的差异gitdiffHEAD# 查看两个提交之间的差异gitdiffcommit1 commit2gitdiffHEAD~1 HEAD# 查看特定文件的差异gitdifffilenamegitdiff--stagedfilename# 查看统计信息gitdiff--statgitdiff--numstat# 查看单词级别的差异gitdiff--word-diff删除和移动文件# 删除文件gitrmfilenamegitrm-ffilename# 强制删除gitrm--cachedfilename# 从暂存区删除但保留工作区文件# 删除目录gitrm-rdirectory/# 移动/重命名文件gitmvold-name new-namegitmvfile.txt directory/# 等价操作mvold-name new-namegitrmold-namegitaddnew-name分支管理分支基础操作# 查看分支gitbranch# 本地分支gitbranch-r# 远程分支gitbranch-a# 所有分支gitbranch-v# 显示最后一次提交gitbranch-vv# 显示跟踪关系# 创建分支gitbranch new-branchgitbranch new-branch commit-hash# 从特定提交创建# 切换分支gitcheckout branch-namegitswitch branch-name# Git 2.23# 创建并切换分支gitcheckout-bnew-branchgitswitch-cnew-branch# Git 2.23# 从远程分支创建本地分支gitcheckout-blocal-branch origin/remote-branchgitswitch-clocal-branch origin/remote-branch分支管理# 重命名分支gitbranch-mold-name new-namegitbranch-Mold-name new-name# 强制重命名# 删除分支gitbranch-dbranch-name# 安全删除gitbranch-Dbranch-name# 强制删除gitbranch--deletebranch-name# 删除远程分支gitpush origin--deletebranch-namegitpush origin :branch-name# 设置上游分支gitbranch --set-upstream-toorigin/maingitbranch-uorigin/main# 查看分支合并状态gitbranch--merged# 已合并的分支gitbranch --no-merged# 未合并的分支分支合并# 合并分支gitmerge branch-name# 快进合并gitmerge --ff-only branch-name# 禁用快进合并gitmerge --no-ff branch-name# 压缩合并gitmerge--squashbranch-name# 合并时指定提交信息gitmerge-mMerge messagebranch-name# 中止合并gitmerge--abort远程仓库远程仓库管理# 查看远程仓库gitremotegitremote-v# 显示详细信息# 添加远程仓库gitremoteaddorigin https://github.com/user/repo.gitgitremoteaddupstream https://github.com/original/repo.git# 修改远程仓库 URLgitremote set-url origin https://github.com/user/new-repo.git# 重命名远程仓库gitremoterenameorigin new-origin# 删除远程仓库gitremote remove origingitremotermorigin# 查看远程仓库信息gitremote show origin推送和拉取# 推送到远程仓库gitpush origin maingitpush origin branch-namegitpush-uorigin main# 设置上游并推送# 推送所有分支gitpush origin--all# 推送标签gitpush origin--tagsgitpush origin tag-name# 强制推送危险操作gitpush--forcegitpush --force-with-lease# 更安全的强制推送# 从远程仓库拉取gitpull origin maingitpull# 从跟踪的远程分支拉取# 拉取但不合并gitfetch origingitfetch--all# 拉取并变基gitpull--rebaseorigin main跟踪远程分支# 查看跟踪关系gitbranch-vv# 设置跟踪关系gitbranch --set-upstream-toorigin/main maingitbranch-uorigin/main main# 推送并设置跟踪gitpush-uorigin feature-branch# 删除远程跟踪分支gitbranch-drorigin/branch-name标签管理创建标签# 轻量标签gittag v1.0gittag v1.0 commit-hash# 附注标签gittag-av1.0-mVersion 1.0gittag-av1.0 commit-hash-mVersion 1.0# 签名标签gittag-sv1.0-mSigned version 1.0标签操作# 查看标签gittaggittag-lv1.*# 模式匹配# 查看标签信息gitshow v1.0# 删除标签gittag-dv1.0# 删除远程标签gitpush origin--deletetag v1.0gitpush origin :refs/tags/v1.0# 推送标签gitpush origin v1.0gitpush origin--tags# 检出标签gitcheckout v1.0gitcheckout-bversion1 v1.0# 基于标签创建分支总结Git 是一个功能强大的版本控制系统掌握其基础用法对于现代软件开发至关重要。本指南仅涵盖基础操作部分而Git 的学习是一个持续的过程随着经验的积累你会发现更多高效的使用方法和高级用法。

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询