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查看
相关推荐
qq_435287923 小时前
第9章 夸父逐日与后羿射日:死循环与进程终止?十个太阳同时值班的并行冲突
java·开发语言·git·死循环·进程终止·并行冲突·夸父逐日
AIMath~10 小时前
Git 子模块(Submodule)目录结构清除实战复盘
git
切糕师学AI11 小时前
Ubuntu 下 Git 完全使用指南
linux·git·ubuntu
一袋米扛几楼9813 小时前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
尘埃落定wf13 小时前
# GitHub CLI:告别繁琐的 Git 命令,让开发更高效
git·github
恋喵大鲤鱼13 小时前
git clone
git·git clone
金牛IT15 小时前
Gogs 轻量级 Git 服务器搭建与使用
运维·服务器·git
Qres8211 天前
Git安装记录
git
wj3055853781 天前
Codex + Git 开发环境配置指南(WSL版)
linux·运维·git
楠枬1 天前
Git 分支管理
git