GitHub的使用

代码的路 -
GitHub的使用

原文链接

创建新项目

在GitHub创建新项目:

github1.png

创建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.
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"

需要到项目的.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 

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

代码的路

公众号二维码.jpg

特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。

Tags 标签

gitgithub

扩展阅读

加个好友,技术交流

1628738909466805.jpg