git预计阅读时间 3 分钟

    Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

    清空本地修改, 恢复至服务端最新版本

    1. git checkout . && git clean -xdf
    2. git pull

    设置文件夹内 local git仓库的用户名和邮箱

    git config user.name "Jansora"
    git config user.mail "zhangyue1936@gmail.com"

    git 代理

    git 配置代理

    git config --global http.proxy 'socks5://127.0.0.1:7890'
    git config --global http.proxy 'socks5h://127.0.0.1:7890'
    git config --global https.proxy 'socks5h://127.0.0.1:7890'
    

    git 清除代理

    git config --global --unset http.proxy
    git config --global --unset https.proxy
    

    git 版本回退

    方法1

    git reset --hard dbf5efdb3cd8ea5d576f2e29fe0db1951d0e3e3b
     
    # 强制推送到远程分支, 会抹去远程库的提交信息, 不要这么干
    # git push -f origin master
    

    方法2

    # 回退到指定版本, 需要解决冲突
    git revert e7c8599d29b61579ef31789309b4e691d6d3a83f
     
    # 放弃回退(加--hard会重置已 commit和工作区 的内容)
    # git reset --hard origin/master 
    

    参考资料

    评论栏