GitHub的使用

作者: 代码的路 | 来源:发表于2022-06-14 11:51 被阅读0次

    原文链接

    创建新项目

    在GitHub创建新项目:

    创建Git文件

    (1)在需要上传的目录打开powershell

    (2)执行命令创建隐藏的.git文件:

    git init

    添加用户

    项目的.git\config文件最后加入

    [user]

       name = name

       email = email

    否则会出现以下报错:

    Commit failed - exit code 128 received, with output: '*** Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"

    添加到Git

    分别执行add、commit,具体参考 Git的使用

    (1)add/rm

    添加需要上传的文件:

    git add env.txt

    或者本地删除了某个文件:

    git rm env.txt

    git add -A表示添加所有内容, git add . 表示添加新文件和编辑过的文件不包括删除的文件; git add -u 表示添加编辑或者删除的文件,不包括新添加的文件

    (2)commit

    对修改的描述

    git commit -m "add env"

    关联仓库

    将本地仓库关联到github上,XXX为仓库名

    git remote add origin https://github.com/Snowstorm0/XXX.git

    Push

    push到github:

    git push -u origin master

    常见报错

    (1)add 时 报错:

    warning: LF will be replaced by CRLF in XXX

    换行符错误,在windows下使用以下代码修改:

    git config --global core.autocrlf true

    (2)add 时 报错:

    fatal: not a git repository (or any of the parent directories): .git

    重新添加git:

    git init

    (3)commit 时 报错:

    Commit failed - exit code 128 received, with output: '*** Please tell me who you are.Rungit config --global user.email "you@example.com"git config --global user.name "Your Name"

    需要到项目的.git\config文件最后加入

    [user]

        name = name

        email = email

    (4)commit 时 报错:

    fatal: could not open '.git/COMMIT_EDITMSG': Permission denied

    对于Windows系统可以进入.git文件(隐藏文件)删除“COMMIT_EDITMSG”文件即可

    (5)push 时 报错:

    fatal: unable to access 'https://github.com/Snowstorm0/': OpenSSL SSL_read: Connection was aborted, errno 10053

    Git默认限制了push的大小,更改限制即可:

    git config --global http.postBuffer 524288000

    学习更多编程知识,请关注我的公众号:

    代码的路

    相关文章

      网友评论

        本文标题:GitHub的使用

        本文链接:https://www.haomeiwen.com/subject/pcwsyrtx.html