git 提交

当你不小心在master上改了代码,并且add, commit 之后,想push,发现根本push不了(本来也不能直接将master代码push到远端),而且每次pull远程master的时候都要和本地的master进行merge ,提示你需要push,烦得很!!

解决:git log 查看commitID ,尽量找早一点的,git reset --hard commitID ,再 git pull 就好了

常用命令:

  1. 切分支

    1. git checkout -b new-branch //新创建分支,并切到新分支
    2. git branch new-branch//新创建一个分支
  2. 查看分支

    1. git branch //查看所有分支
    2. git branch -a //查看所有分支,包括远程和本地
  3. 合并分支

    1. git merge master //把指定的master分支合并到当前分支
    2. 解决冲突:====== 标记之前的内容来自于接收合并的分支,而在这之后的内容来自于要合并的分支。
    复制代码
        <<<<<<< main
    
       this is conflicted text from main
    
       =======
    
       this is conflicted text from feature branch
    
        >>>>>>> feature branch;
  4. 删除分支

    1. git branch -d my-branch
  5. 提交代码

    1. git add *
    2. git commit -m "debug"
    3. git push
  6. 回滚数据

    1. git reset --soft
    2. git reset --mixed
    3. git reset --hard "commit-id"// git log查看
相关推荐
鶴哥只手遮天4 小时前
第 8 章 工作区与检出:unpack-trees 与并行 checkout
git
xing-xing6 小时前
git 相关命令总结
git
A-刘晨阳8 小时前
GitLab + ArgoCD 实现 Kubernetes GitOps 自动化部署
运维·人工智能·git·kubernetes·自动化·云计算·argocd
ControlRookie19 小时前
SyncBridge:一个 CODESYS 工程与 AI 之间工程师级的同步工具
git·ai编程·codesys·工业软件·controlrookie
鬼手点金1 天前
opencode-性能优化建议
java·人工智能·git·自动化·nanogpt
网络毒刘1 天前
开源 Aider 工作流实战:Git 提交驱动的 AI 结对,与 Cursor 何时互补
git·ai编程·cursor·aider
HRTOS1 天前
HRTOS 4.0 将长期维护:为什么版本号不再频繁变化
经验分享·git·单片机·51单片机
驭渊的小故事2 天前
linux 基础命令 + git 仓库创建和配置命令
linux·git
行者-全栈开发2 天前
华为云码道 CodeArts 实测:让 AI 用 Rust 写一个 Git 仓库健康度体检台「仓衡」
git·rust·tauri·桌面应用·ai 编程·华为云码道·codearts 代码智能体
挖掘狂人4 天前
Git 从 0 到 1:用一个小项目走完 add / commit / reset / merge / rebase / push
git·后端·github