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的问题解决_风随心飞飞的博客-CSDN博客
项目根目录下:打开git-bash,使用命令:ssh-keygen -t rsa -C 你的邮箱地址
可以在用户主目录(WINDOWS系统中,例如:C:\Users\用户名\.ssh)里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,将id_rsa.pub里面的内容复制粘贴到github站点的SSH公钥中即可。