当你不小心在master上改了代码,并且add, commit 之后,想push,发现根本push不了(本来也不能直接将master代码push到远端),而且每次pull远程master的时候都要和本地的master进行merge ,提示你需要push,烦得很!!
解决:git log 查看commitID ,尽量找早一点的,git reset --hard commitID ,再 git pull 就好了
常用命令:
- 切分支 - git checkout -b new-branch //新创建分支,并切到新分支
- git branch new-branch//新创建一个分支
 
- 查看分支 - git branch //查看所有分支
- git branch -a //查看所有分支,包括远程和本地
 
- 合并分支 - git merge master //把指定的master分支合并到当前分支
- 解决冲突:====== 标记之前的内容来自于接收合并的分支,而在这之后的内容来自于要合并的分支。
-  <<<<<<< mainthis is conflicted text from main=======this is conflicted text from feature branch>>>>>>> feature branch;
 
- 删除分支 - git branch -d my-branch
 
- 提交代码 - git add *
- git commit -m “debug”
- git push
 
- 回滚数据 - git reset --soft
- git reset --mixed
- git reset --hard “commit-id”// git log查看
 
