Introduction: the accumulation of some code, before the disk is stored in the cloud. Later discovered Git, very easy to use, but the operation is a little bit cumbersome, Mark it. I had wanted to use GitHub, but I heard that open source is also subject to US export controls, was unhappy with the.

1, registration code cloud account, log in and create a new warehouse. Can be found in the Help Center:https://gitee.com/help/articles/4120

image.png

Fill in the necessary information

image.png

2, download and install Git: https://git-scm.com/

About Git is what can be found here: https://www.liaoxuefeng.com/wiki/896043488029600/896067008724000

image.png

When installed, the location of choice Notepad ++. If the computer is not this software, you can install a go.

image.png


3, there are two ways to access cloud yards, one is the account password, the other is ssh keys.

3.1, an access code via cloud account password

3.1.1, first create a private warehouse

image.png


3.1.2, enter the warehouse, copy the address in the following location

image.png


3.1.3, open a disk directory, right in the directory, and then choose Git Bash Here open.

image.png


3.1.4, enter the command in the console window: Copy the address before git clone

It will pop up an account password input box

image.png


3.1.5, enter the code cloud account password, you can complete clone

image.png

3.1.6, account number and password in the windows Credential Manager, the next time you use the clone and push operations do not have to fill in your password.

Desktop lower left corner point search, enter Credential Manager, you can find and view.

image.png

image.png


3.2, using ssh keys cloud access code

3.2.1, first need to generate ssh key in the console input: ssh-keygen -t rsa -C "[email protected]"  

Next will be prompted to enter the key save path:

image.png


3.2.2, enter the password

image.png


3.2.3, enter the password again

image.png


3.2.4, the build is complete:

image.png


3.2.5、找到密钥保存路径,用Notepad++打开公钥,复制里面的内容。(Tips:图片展示密钥的是演示所用,切记注意保管好你自己的密钥!!!

image.png


3.2.6、打开码云,找到公钥管理页面

image.png

把之前复制的公钥粘贴到下图的位置:


image.png


3.2.7、使用ssh密钥clone。

首先复制地址,在磁盘目录打开Git Bash,输入指令:git clone 复制的地址,即可把工程clone到对应的磁盘目录下

image.png

image.png


4、同步到码云

4.1、在clone的目录里打开Git Bash,放入修改好的工程。

放入之前最好用清理工具清理一下,减小体积。写了一个VS的清理工具,在这里:https://gitee.com/shihuozhiyu/VS-Cleaner

然后依次执行以下指令:git add .        (指令作用:添加目录下所有文件到暂存区)

image.png


4.2输入指令:git commit -m "备注"

image.png


4.3输入指令:git push

image.png


4.4登录仓库查看一下,多了以一个添加的工程,同步完成。(账号和ssh两种方式,同步的步骤都是一样的)。

image.png


5、Git常用指令

创建新文件夹: mkdir 文件夹名

切换文件夹:    cd 文件夹名

初始化Git仓库:git init

添加文件到仓库:git add 文件名.扩展名

                            git commit -m“信息”

查看仓库状态:git status

查看提交日志:git log

显示一行日志:git log --pretty=oneline

版本回退:git reset --hard HEAD^    

               (HEAD指当前版本,HEAD^指上一个版本,HEAD~100指往上100个版本)

                 git reset --hard 版本号

显示文件内容:cat 文件名.扩展名

查看命令历史:git reflog

撤销工作区的修改: git checkout -- readme.txt

撤销暂存区(文件add,但是没有commit)的修改: 第1步、git reset HEAD readme.txt

                                                                                第2步、git checkout -- readme.txt

从版本库删除文件:第1步、git rm readme.txt

                               第2步、 git commit -m "delete"

从工作区删除文件:rm readme.txt

从工作区恢复文件:git checkout -- readme.txt

查看分支:git branch

切换分支:git checkout master

创建标签:git tag v1.0(在当前所在的分支)

                 git tag v0.9 f52c633(历史提交的commit id)

                 git tag -a tagname -m "blablabla..."(指定标签信息)

查看标签:git tag

查看标签信息:git show 标签  

删除本地标签:git tag -d v0.1

删除远程标签:git push origin :refs/tags/v0.9(先删除本地)

推送单个标签:git push origin v1.0

Push all not push the label: git push origin --tags            

Associated with the remote repository: git the Add Remote Origin [email protected] : Custom Name / warehouse name .git

View Gallery: git remote -v

Delete library: git remote rm origin

The clone remote repository to local: git clone https://gitee.com/ custom name / warehouse name

Add the current directory of all files to the staging area git: git add.

Remarks submitted and submit information: git commit -m "my first commit"

The local commit pushed to the remote repository: git push origin master

Discard the file online, choose to push in the push: git push origin master -f

Reservations line readme file, you need to perform: git pull origin master