GIT基本使用记录

1、git配置与查看用户名与邮箱命令:

git config --global user.name "your name"
git config --global user.email "your_email@163.com"
git config --global --list
 

如果不设置相关的用户名与邮箱,使用相关commit命令时,会有如下提示:

D:\JavaProjects\imooc-news-dev>git commit -m "first commit"

*** Please tell me who you are.

Run

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

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'username@username.(none)')

2、基本的使用命令如下:

git add .
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:AlickLiubc/imooc-news.git
git push -u origin main

遇到如下问题的解决方案参考:

D:\JavaProjects\imooc-news-dev>git push -u origin main
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAabcdf/R1Bfeef3/LiyKfessfQM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

git@github.com: Permission denied (publickey). fatal: Could not read from remote repository的问题解决_风随心飞飞的博客-优快云博客

项目根目录下:打开git-bash,使用命令:ssh-keygen -t rsa -C 你的邮箱地址

可以在用户主目录(WINDOWS系统中,例如:C:\Users\用户名\.ssh)里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,将id_rsa.pub里面的内容复制粘贴到github站点的SSH公钥中即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值