Git命令学习笔记

基本操作

git init //初始化命令

git add //添加到暂存区 工作区→暂存区

git commit // 提交到版本库 暂存区→版本区

git commit --allow-empty 允许空commit,打开文件型提交

git log //查看log

git status//查看状态

回滚

git reset --hard [commit ID] //版本区-回滚->commit ID

git reset HEAD file_name //暂存区的内容-回滚->工作区状态

git reflog //查看回滚前的log

git reset --soft [commit ID] //软回滚,commit信息回滚,但代码依然在

分支

git branch 查看分支

git branch branch_name//当前枝条下创建分支

git checkut branch_name//切换分支

git merge other_branch//其他分支合并到当前分支
(可能会产生冲突)

git branch -d branch_name //删除分支

gitHub仓库

1.注册
2.建立仓库
3.推送

git remote add origin web_adr //仓库别名

git clone web_adr//克隆仓库中的代码

git push (-u 设置默认用) origin branch_name //推送到网站仓库

git pull origin branch_name//从网站仓库中拉下分支

git pull origin branch_name = git fetch origin branch_name + git merge origin branch_name

★git rebase//目的:使git提交记录变得简洁

应用场景

git rebase -i HEAD~3
git log --graph//以流程图片的方式显示提交日记
git log --graph --pretty=format:"%h %s"

解决冲突

借助git自带的软件即可解决冲突

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

青草地溪水旁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值