git 常用命令

本文详细介绍了Git中常用的命令操作,包括如何克隆仓库、切换和管理分支、查看和提交更改,以及如何进行代码拉取等核心流程。特别强调了浅克隆(--depth=1)的使用场景和方法,适合于开发者快速掌握Git的基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

clone

  1. git clone --depth=1 https://github.com/Dervon/xxxxxxx.git 克隆最新一次更新
  2. git clone --depth 1 https://github.com/Dervon/xxxxxxx.git 克隆最新一次更新,同上,区别在于将“=”换成了空格
  3. git clone https://github.com/Dervon/xxxxxxx.git 克隆所有

分支相关

切换分支

git checkout sunxi-next

列出所有分支

git branch -a

git clone --depth=1 git…git后拉取其他分支

$ git clone --depth 1 https://github.com/Dervon/xxxxxxx.git
$ git remote set-branches origin ‘sunxi-next’
$ git fetch --depth 1 origin sunxi-next
$ git checkout sunxi-next

提交相关

git status
git diff
git reset --hard commit_id 退到/进到 指定commit的sha码
git remote -v 查看git信息
git clean -f 和 git reset --hard 工作目录完全回退到最近一次commit的时候.
git format-patch 0163bed3bf59ae74c36cc5138b4c24f1556d8304 -1 生成patch文件

git commit -m"提交信息" 和git push配合提交代码

拉取相关

git pull “origin”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值