git使用--02

git的3个区

工作区----本地工作目录
暂存区----git add之后的文件位置
版本区----git commit之后的文件位置

暂存区+版本区即为版本库

git操作

git对比

工作区与暂存区比较
    git diff
工作区与版本库比较
    git dif master
暂存区与版本库比较
    git diff --cached

git撤销

从暂存区撤销提交
    git reset HEAD index.html
从版本库撤销提交
    git commit -m "msg"  --amend   # 撤销上次提交并合并本次提交
从版本库回滚
    git checkout index.html

git删除

从本地删除
    git rm index.html
从暂存区删除
    git rm --cached index.html
同时删除本地和暂存
    git rm -f index.html

git恢复

从暂存区恢复
    git reset HEAD index.html
从版本区恢复
    git checkout 版本号 index.html
    git reset --hard 版本号           # 恢复整个版本

git远程管理

git冲突解决

场景:多人协作,本地不是最新pull的代码,远程分支已有修改
    拉取代码
        git fetch
    对比本地master分支与远程master分支
        git diff master origin/master
    手动把远程master分支与本地master分支合并,经过讨论后手动合并
        git merge origin/master
    重新提交推送
发布了114 篇原创文章 · 获赞 7 · 访问量 5376

猜你喜欢

转载自blog.csdn.net/qq_25672165/article/details/104945510
今日推荐