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查看
相关推荐
likuolei3 小时前
Git 与 SVN 区别
git·svn
charlee448 小时前
Git使用经验总结8-Git仓库历史记录清除
git·powershell·敏感信息·仓库重置·历史重写
正经教主9 小时前
【Git】Git05-04:Github分支管理与协作流程
git·github
sean90811 小时前
git filter-repo(优秀的 git repo 历史重写工具) 实战
git·repo·工具
hen3y11 小时前
清理 Git 代码库大文件历史记录
运维·git
小Lu的开源日常12 小时前
踩坑日记:为什么Git 突然 Push 不上去了
git·ssh·github
LZ7工作室12 小时前
MAC编程:在MACOS安装和使用 Git 的方法
网络·git·macos·github·个人开发
T***160715 小时前
Git增强现实案例
git·ar
Arva .16 小时前
git常用
git
久莜17 小时前
【Git】使用教程
git