当前位置: 首页 > news >正文

工作中常用的git命令,千万不能忘

1、设置当前分支为默认分支:
    git branch –set-upstream-to=origin/master

2、To push the current branch and set the remote as upstream, use:
    git push --set-upstream origin eds_enhancement

3、同步远程分支
    git remote update --prune [remote]

4、Remove a file from a Git repository without deleting it from the local filesystem
    For single file:
    git rm --cached mylogfile.log

    For single directory:
    git rm --cached -r mydirectory

5 undo git add . from staged
    git reset
    git reset <file path>

    or undo all staged files:
    git reset HEAD .

6 commit to gateWay
    git push origin HEAD:refs/for/19.1.1_sparkle


7 撤销提交
    git revert [commit id]

8 查看文件变动
    git show --name-only {commit}

9 squash commits to one(将多个commits压成一个)
    git rebase -i [commit-id (not contained it)] 

    note: 
        select by `s` short command

10 在最近的commit上追加文件变动
    git add the_left_out_file
    git commit --amend --no-edit

    or 

    git reset HEAD^
    git add again


11 撤回部分file的commit
    step 1: git reset --soft HEAD^1
    step 2: git reset <file path>
    git rm --cached <file-name>(如果要刪除此文件)

12 恢复reset
    git reflog


13 list all conflict files
    git diff --name-only --diff-filter=U


14 add message to stash command
    git stash save <messages>


15 rebase local branch with remote master
    step1: git fetch origin            # Updates origin/master
    step2: git rebase origin/master    # Rebases current branch onto origin/master

16 change commit message to latest commit
    git commit --amend -m "New commit message."


17 git log --author=<author name>

18 git alias
     git config --global alias.p 'push'
     git p

http://www.lryc.cn/news/212994.html

相关文章:

  • 计组之存储系统
  • 【Jenkins】新建任务FAQ
  • 生产环境使用boost::fiber
  • TSINGSEE青犀AI视频识别技术+危化安全生产智慧监管方案
  • 小程序request请求封装
  • Easy Javadoc插件的使用教程
  • 一篇文章让你弄懂Java中的方法
  • SAP MM学习笔记39 - MRP(资材所要量计划)
  • 总线类设备驱动——IIC
  • MES 的价值点之动态调度
  • dfs序及相关例题
  • python入门实战:爬取图片到本地
  • day02 矩阵 2023.10.26
  • 浪潮信息inMerge超融合 刷新全球vSAN架构虚拟化VMmark最佳成绩
  • 【【哈希应用】位图/布隆过滤器】
  • OpenCV学习笔记
  • idea 一键部署jar包
  • 16、SpringCloud -- 常见的接口防刷限流方式
  • Typora(morkdown编辑器)的安装包和安装教程
  • 服务器不稳定对网站有什么影响
  • py实现surf特征提取
  • MS39233三个半桥驱动器可兼容TMC6300
  • 09、SpringCloud -- 利用redis的原子性控制高并发请求访问到service层、本地标识
  • 竞赛选题 深度学习图像修复算法 - opencv python 机器视觉
  • 基于深度学习网络的美食检测系统matlab仿真
  • 人工智能基础_机器学习006_有监督机器学习_正规方程的公式推导_最小二乘法_凸函数的判定---人工智能工作笔记0046
  • 【MongoDB】Windows 安装MongoDB 6.0
  • DM8 Dokcer镜像更新后远程无法jdbc连接问题
  • AI:39-基于深度学习的车牌识别检测
  • 软考 系统架构设计师系列知识点之系统架构评估(1)