GitHub的使用

电子说

1.2w人已加入

描述

创建新项目

在GitHub创建新项目:

C++

创建Git文件

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

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

git init

添加用户

项目的.gitconfig文件最后加入

[user]
    name = name 
    email = email

否则会出现以下报错:

Commit failed - exit code 128 received, with output: '*** Please tell me who you are.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

添加到Git

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

(1)add/rm

添加全部文件:

git add -A

添加单个文件:

git add env.txt

删除某个文件:

git rm env.txt

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

(2)commit

对修改的描述

git commit -m "new"

关联仓库

将本地仓库关联到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.

Run

git config --global user.email "you@example.com"

git config --global user.name "Your Name"

需要到项目的.gitconfig文件最后加入

[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

  审核编辑:汤梓红

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分