Git命令学习笔记

Git命令详解

  • 简介
    • 什么是Git
    • Git的优势
    • Git的工作原理

配置Git

  • git config
    • 配置用户信息
      • git config --global user.name "Your Name"
      • git config --global user.email "youremail@example.com"
    • 查看配置信息
      • git config --list

初始化仓库

  • git init
    • 初始化一个新的Git仓库

克隆仓库

  • git clone
    • 克隆一个远程仓库
      • git clone <repository-url>

添加文件到暂存区

  • git add
    • 添加指定文件到暂存区
      • git add <file>
    • 添加所有文件到暂存区
      • git add .

提交更改

  • git commit
    • 提交暂存区的更改
      • git commit -m "commit message"

查看状态

  • git status
    • 查看当前仓库的状态

查看提交历史

  • git log
    • 查看提交日志
    • 常用选项
      • --oneline:简洁日志格式
      • --graph:图形化显示分支和版本演进

撤销更改

  • git checkout
    • 撤销工作区的修改
      • git checkout -- <file>
  • git reset
    • 将暂存区的修改撤销
      • git reset HEAD <file>
    • 将提交的修改撤销
      • git reset --hard <commit-hash>

分支管理

  • git branch
    • 查看分支列表
    • 创建分支
      • git branch <branch-name>
    • 删除分支
      • git branch -d <branch-name>
  • git checkout
    • 切换到指定分支
      • git checkout <branch-name>
    • 创建并切换到新分支
      • git checkout -b <branch-name>
  • git merge
    • 合并指定分支到当前分支
      • git merge <branch-name>

远程仓库操作

  • git remote
    • 查看远程仓库列表
    • 添加远程仓库
      • git remote add <remote-name> <repository-url>
    • 删除远程仓库
      • git remote remove <remote-name>
  • git fetch
    • 获取远程仓库的更新
      • git fetch <remote-name>
  • git pull
    • 拉取远程仓库的更新并合并到本地分支
      • git pull <remote-name> <branch-name>
  • git push
    • 推送本地分支的更新到远程仓库
      • git push <remote-name> <branch-name>

标签管理

  • git tag
    • 查看标签列表
    • 创建标签
      • 轻量级标签:git tag <tag-name>
      • 带附注的标签:git tag -a <tag-name> -m "tag message"
    • 删除标签
      • git tag -d <tag-name>
  • git push
    • 推送标签到远程仓库
      • git push <remote-name> <tag-name>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值