Git安装包地址:链接: Git
Windows下载运行exe文件 安装之后可运行Git Bash
–global默认全局配置
$ git config --global user.name "xxxx"
$ git config --global user.email test@xxx.com
可使用以下命令查看配置信息
$ git config --list
$ ssh-keygen -t rsa -C "youremail@example.com"
引号中是你Github的使用的邮箱
$ ssh-keygen -t rsa -C "youremail@example.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/tianqixin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): # 直接回车
Enter same passphrase again: # 直接回车
Your identification has been saved in /Users/tianqixin/.ssh/id_rsa.
Your public key has been saved in /Users/tianqixin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:MDKVidPTDXIQoJwoqUmI4LBAsg5XByBlrOEzkxrwARI youremail@example.com
The key's randomart image is:
+---[RSA 3072]----+
|E*+.+=**oo |
|%Oo+oo=o. . |
|%**.o.o. |
|OO. o o |
|+o+ S |
|. |
| |
| |
| |
+----[SHA256]-----+
在 ~/ 下生成 .ssh 文件夹,进去,打开 id_rsa.pub,复制里面的 key
浏览器打开Github,进入Settings,如下图所示
点击SSH and GPG keys
点击new SSH key
将复制的SSH粘贴到key框内,即可添加成功。
添加成功后,在Git Bash中使用以下命令验证是否添加成功。
$ ssh -T git@github.com
Hi xxxxx! You've successfully authenticated, but GitHub does not provide shell access.
并出现上面的提示即为添加成功。
在Github上创建一个新的仓库
创建成功后得到如下结果
可根据提示选择在命令行创建一个仓库,或者将本地仓库推送到该远程仓库,可根据相应命令执行。
$ git init # 初始化
$ git add README.md # 添加文件
$ git commit -m "添加 README.md 文件" # 提交并备注信息
[master (root-commit) 0205aab] 添加 README.md 文件
1 file changed, 1 insertion(+)
create mode 100644 README.md
# 提交到 Github
$ git remote add origin https://github.com/username/Testrepo.git #注意该条命令需修改为自己仓库的地址
$ git push -u origin master
由于Github不能稳定访问的缘故,转而换成Gitee作为托管平台,其连接形式过程与 github相似,推送时注意仓库链接地址。 这里说一下将推送到Gitee的仓库自动Push到Github中
(1)在你选择的仓库页面,点击管理,之后点击仓库镜像管理
点击添加镜像,初次使用可能需要选择github授权,授权即可。
之后选择是推送到github上还是从github上拉取,根据自己的需要选择,然后在镜像仓库中选择自己需要Push或者Pull的仓库
私人令牌则是在github上手动设置的token复制粘贴到此处即可。 创建token的步骤如下所示developer setting
根据图示选择generate new token
然后根据需要生成新的token,并复制使用。