文章目录
创建远程git仓库
如图:
配置仓库信息
说明:
- 是否开源: 选择公开即可
- 语言选择,根据自己的实际编程语言选择,添加什么许可证,我这里一般选择GPL,具体可以根据说明查看,此项主要是针对与仓库转载及修改权限的设置等。
保存
选择保存之后,我们的远程初始仓库即可创建成功。
克隆远程仓库到本地
选择我们在远程仓库的地址,可以选择http的地址,也可以选择ssh地址然后在本地Git Bash Here客户端操作命令行进行下载提交即可,** 前提是要在本地主机上安装git **,这里不再说明如何安装git。
第一步:git添加ssh公钥
** 1.添加git配置信息**
显示当前的Git配置
$ git config --list
编辑Git配置文件
$ git config -e [–global]
设置提交代码时的用户信息
$ git config [–global] user.name “[name]”
$ git config [–global] user.email “[email address]”
2.删除本地的unknow.ssh文件
进入本地文件夹目录:C:\Users\Administrator.ssh 目录下面,若已经存在文件id_rsa(私钥文件)和id_rsa.pub(公钥文件),就不需要进行2、3后面步骤,说明已经存在ssh公钥。
3.生成ssh公钥
若步骤2中没有那俩个文件,同时已经删除unknow文件之后,我们在本地git bash命令行执行以下命令,同时后续一直按enter键即可,生成ssh公钥及私钥:
ssh-keygen -t rsa -C “example@qq.com”
$ ssh-keygen -t rsa -C "example@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:nEGf8C6s24uICT4IC1cQCsJZm4i6/VwAtL7rriOYI4w dhjtobenumber1@163.com
The key's randomart image is:
+---[RSA 3072]----+
|+ =o o |
|+=o.o . + . |
|o.o+ . + |
|.. .. o + |
|. ... S . |
|oo.. . . . |
|X+o o |
|E+ * o + |
|+BB + o o. |
+----[SHA256]-----+
见上shell命令,即代表ssh公钥及私钥生成成功,生成的路径在:C:\Users\Administrator.ssh 目录下,我们进入此目录查看是否存在id_rsa(私钥文件)和id_rsa.pub(公钥文件)俩个文件,若存在则代表生成成功。
第二步,将本地的公钥文件添加到gitee中
复制本地的id_rsa.pub文件内容至码云中个人设置中的ssh公钥设置点击确定按钮即可添加成功:如图:
第三步:将远程仓库clone到本地目录
前面的步骤及配置执行完成之后,我们在要存放要下载的仓库的文件夹下打开git bash命令窗口:
- 在码云中要clone的仓库上选择对应的ssh地址,复制
- 在git bash窗口执行命令直到done即可克隆完成:
git clone git@gitee.com:xxx/springcloud-config.git
3.查看本地目录文件中克隆的仓库是否与远程仓库一致。
第四步:提交本地新增文件到远程仓库
- 在上诉克隆到本地目录下的仓库中新增文件application.yml文件
- 依次执行以下命令将文件提交到远程仓库:
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ git pull origin master
From gitee.com:denghuaijun2020/springcloud-config
* branch master -> FETCH_HEAD
Already up to date.
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ gitt add .
bash: gitt: command not found
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ git add .
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ ls
LICENSE README.en.md README.md application.yml
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)
$ git push origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 394 bytes | 98.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To gitee.com:denghuaijun2020/springcloud-config.git
a4b99c0..d03a3aa master -> master
Administrator@XTTD-2020KLKCIP MINGW64 /e/springcloudconfig/springcloud-config (master)