• Git常用命令


    本地关联Github

    git config --global user.name "xxx"
    git config --global user.email "xxx@qq.com"
    ssh-keygen -t rsa -C "xxx@qq.com"
    cat .ssh/id_rsa.pub 
    
    • 1
    • 2
    • 3
    • 4

    之后将这坨代码粘贴到github里面的setting中

    ssh -T git@github.com

    参考资料:https://www.jianshu.com/p/7edb6b838a2e


    常用命令

    add:git add --all
    提交代码:git commit -m "xxx"
    将提交的内容push到仓库:git push -u origin master
    查看当前分支:git branch
    按分支进行克隆:git clone -b hexo httpxxxx.git

    只输入一次github密码:git config --global credential.helper store
    (参考自:https://blog.csdn.net/ds19980228/article/details/83720450)

    https://pages.github.com/

    放弃本地所有修改: git checkout .


    错误解决

    git报错ssh: connect to host github.com port 22: Connection timed out
    解决方案(亲测有效)

    1. 在C盘——用户——你的主机名文件夹中找到.ssh文件夹;(此前配置SSH时会生成该文件夹)
    2. 在.ssh文件夹中新建文件 config,不带后缀(可以新建文本文档,去掉.txt后缀)
    3. 使用notepad++(或其他方式)打开config文件,输入以下内容,保存后即可
    Host github.com
    User YourEmail(你的邮箱)
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    再次执行

    ssh -T git@github.com
    
    • 1

    会出现以下提示,输入yes回车即可

    The authenticity of host '[ssh.github.com]:443 ([192.30.255.123]:443)' can't be established.
    RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[ssh.github.com]:443,[192.30.255.123]:443' (RSA) to the list of known hosts.
    
    • 1
    • 2
    • 3
    • 4

    参考资料:https://blog.csdn.net/hdm314/article/details/119947761
    参考资料:git放弃本地文件修改

  • 相关阅读:
    FFmpeg开发笔记(七)欧拉系统编译安装FFmpeg
    问题问题问题
    JavaScript 基本语法及概念
    力扣(674.160)补8.30
    编程语言未来发展趋势之我见
    JavaFX之Scene Builder的使用(开发一款GUI小工具原来这么简单)
    达梦数据库使用中遇到的问题和解决方案
    输运方程的推导
    linux添加了公钥后,ssh登录却还需要密码
    JDBC批量插入数据
  • 原文地址:https://blog.csdn.net/MASILEJFOAISEGJIAE/article/details/126159016