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查看
相关推荐
1379003408 小时前
Git 设置代理
git
xiaodunmeng14 小时前
sourcetree gitee 详细使用
git
LostSpeed16 小时前
git,gitea - tool - creat Gitea Empty Rep Dir
git·gitea
前端郭德纲18 小时前
vscode默认终端怎么设置成git bash
git·vscode·bash
近听水无声4771 天前
git 学习(基于Ubuntu和gitee)
git
2401_826097622 天前
同步&异步日志系统-日志落地模块的实现
c++·git·vim
半旧夜夏2 天前
阿里云IOT消息处理
java·ide·git·物联网·spring·阿里云
我们的五年2 天前
【Git版本控制器】第三弹——版本回退,撤销修改,删除文件
大数据·linux·git
一名嵌入式糕手2 天前
Git从基础到进阶
git
不cong明的亚子2 天前
github用户名密码登陆失效了
git·github