git上传github

git上传github

  1. 创建仓库文件夹(任意位置),打开git Bash Here

    image-20240922104125509

  2. 初始化git

    image-20240922104243033

    输入

    git init
    

    生成该文件夹

    image-20240922104357825

    输入上传的信息

    git config --global user.name "用户名"
    
    git config --global user.email "邮箱"
    

    image-20240922104734831

    复制需要上传的文件

    输入

    git add .
    

    image-20240922105037520

    输入检查状态

    git status
    

    image-20240922105127707

    输入提交说明

    git commit -m "输入自己的说明"
    

    image-20240922105251777

    查看提交日志

    git log
    

    image-20240922105320347

  3. 配置github公钥

    image-20240922105427202

    image-20240922105448664

    image-20240922105502353

  4. 创建密钥

    输入,直接回车(无需密码),需要设置密码可自己设置

    ssh-keygen
    

    image-20240922105619601

    找到公钥存储位置

    image-20240922105901051

    打开公钥复制粘贴到github中

    image-20240922110046268

    保存

  5. 检查是否连接正常

    image-20240922110226433

    如出现

    ssh: connect to host github.com port 22: Connection refused
    

    可在.ssh中创建config文件可解决

    image-20240922110351110

    Host github.com
    Hostname ssh.github.com
    Port 443
    

    image-20240922110434631

    显示successflly即可

  6. 上传

    复制仓库的ssh地址

    image-20240922110642576

    输入

    git remote add origin 地址
    

    image-20240922110848706

    输入

    git push origin master
    

    image-20240922110956669

    上传成功

    image-20240922111028359

posted @ 2024-09-22 11:25  1999LIJIAN  阅读(16)  评论(0)    收藏  举报