第一步:安装git,配置用户名、邮箱,生成公钥私钥等
$ git init
Initialized empty Git repository in F:/gitcode/.git
$ git config --global user.name "Tianer"
$ git config --global user.email "2579091442@qq.com"
$ git config --global --list
user.name=Tianer
user.email=2579091442@qq.com
$ ssh-keygen -t rsa -C"2579091442@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/80006257/.ssh/id_rsa):
Created directory '/c/Users/80006257/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/80006257/.ssh/id_rsa.
Your public key has been saved in /c/Users/80006257/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:0SqpX0n0x2LIJJbdiDNou9vqBf3CN7KiDUUF45zMCG4 2579091442@qq.com
The key's randomart image is:
+---[RSA 3072]----+
|. o.. |
|.. * = + + |
| E. X B * o |
|. o + O = . |
| + + S + o |
| . = + o o |
| . o = * |
| o.= * . |
| .o=o+ |
+----[SHA256]-----+
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDtY/SUFUiLiV79o+ByyGELet7VOmo4/pdFmXKbKpKVUiYN9hAPqxLoh8GuccdZQgb/VPE5hdyUDMTdsAn+6E9mlO1/ZqTQai5eJXm3KybpjWIX2eXy82QKKtcmJIV4tQIY0hTIHUbTUjTbvpz1roRtzdEOSiWWSOxplXgmk/0hAEqRhnMbIOOeEm+6xQJVQJoPk9aZreWwnmWdAPs1MYGBUbbFAstwqYW4wC+oVwM1TX20B52JNPbbCK33weWTsjUMvY41U7OnVKiTX0k+v/35vh8+93o9VBFKKDpHllvpORWxQ9bOuO1wTgsD2fYDRYBooL08ytSWblAz2kYddoa1Ak5G916cCmn5DuRhpBKhSP1zzkQ+86WUWzvk4eyFB64BlReeX+TQHRTf2uJN/UtB9FKISR72eaDaxW3PWLHTLR8Oo+creFmd4vOkUZMKNbJOxywdODL651ry+bjTPCdvOaS95Pkbz4EO9SDSkCBz1wFCYVqUdlYMSC3BR8KUZOE= 2579091442@qq.com
第二步:注册gitee,新建仓库,并复制远程地址
第三步:用pychar打开项目,在终端完成如下操作,把客户端的初始代码和服务器的版本库关联起来
#创建版本项目同名文件夹,并执行初始化
E:\InterFrame>git init
Initialized empty Git repository in E:/InterFrame/.git/
#关联到已经创建的版本库
E:\InterFrame>git remote add origin https://gitee.com/tianner001/inter-frame.git
#初始化版本库到本地master分支
E:\InterFrame>git pull origin master:master
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 1.42 KiB | 9.00 KiB/s, done.
From https://gitee.com/tianner001/inter-frame
* [new branch] master -> master
* [new branch] master -> origin/master
#设置默认分支和上传代码的分支
E:\InterFrame>git branch --set-upstream-to=origin/master master
Branch 'master' set up to track remote branch 'master' from 'origin'.
E:\InterFrame>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Already up to date.
第四步:在项目下右键Git GUI Here复制全部要提交的代码,然后Commit---Stage to Commit---写备注信息---Sign Off---Commit---Push
备注:你也可以先clone代码下来,然后导入到你的编辑器Pycharm或者idea里,如果是更改把本库地址了,那么先执行如下命令来删除版本库关联再执行
git remote rm origin
git remote add origin https://gitee.com/tianner001/inter-frame.git
git pull origin master:master
git branch --set-upstream-to=origin/master master
git pull