常用git命令

好久没写总结了,有时候时间久了就忘了自己都碰到的问题及解决办法
前期配置

git 初始化配置
  • git config --global user.name
  • git config --global user.email
查看所有配置信息
  • git config --list
对应流程
  1. 先克隆代码git clone https
  2. 创建自己的分支,并切换分支 git checkout -b name
  3. 在自己的分支上开发代码
  4. git add .
  5. git commit -m ‘提交注释’
  6. git push origin 分支名
  7. git mergin
    提交代码中:
合并commit

git checkout 主分支
git pull 更新代码
git checkout 自己分支
git rebase -i 主分支
git push origin 自己分支

git rebase -i 主分支时

遇到冲突,解决冲突,然后add,继续git rebase --continue
遇到冲突,不想解决冲突 git rebase --abort

不想提交代码,保存在当前分支,git stash暂存当前工作

常用命令
git stash list 查看stash记录
git stash save ‘备注’ 保存代码至队列
git stash pop stash@{i} 使用某个stash代码,并移除对应的stash
git stash apply stash@{i} 使用某个stash代码,不移除对应的stash
git stash drop stash@{i} 移除某个stash
git stash clear 删除所有的暂存
git stash show 查看具体的记录
晚上下雨,躺在暖和的被窝里玩着电脑真爽

git log查看提交记录

git log --oneline 查看历史提交记录
git reset --soft commitId 回退commit
git reset --hard commitId 回退commit

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值