多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ------ ### 首先在码云创建一个仓库 <img src="https://gitee.com/codeyuany/TyporaImages/raw/master//images/image-20210831203305946.png" alt="image-20210831203305946" style="zoom: 67%;" /> > 创建好后拿到这个仓库的地址:https://gitee.com/codeyuany/git.git > 全局设置 > > 首先可以在自己的本地环境中设置一下自己的一些个人信息 ```shell git config --global user.name "yong.yuan" git config --global user.email "1218639030@qq.com" ``` > 设置好以后可以通过`config`相关的一些命令来查看一下已经配置好的信息。 ``` [root@supman ~]# git config usage: git config [options] Config file location --global use global config file --system use system config file --local use repository config file -f, --file <file> use given config file --blob <blob-id> read config from given blob object Action --get get value: name [value-regex] --get-all get all values: key [value-regex] --get-regexp get values for regexp: name-regex [value-regex] --replace-all replace all matching variables: name value [value_regex] --add add a new variable: name value --unset remove a variable: name [value-regex] --unset-all remove all matches: name [value-regex] --rename-section rename section: old-name new-name --remove-section remove a section: name -l, --list list all -e, --edit open an editor --get-color <slot> find the color configured: [default] --get-colorbool <slot> find the color setting: [stdout-is-tty] Type --bool value is "true" or "false" --int value is decimal number --bool-or-int value is --bool or --int --path value is a path (file or directory name) Other -z, --null terminate values with NUL byte --includes respect include directives on lookup ``` > 例如获取一下配置列表 ```shell [root@supman ~]# git config -l user.name=yong.yuan user.email=1218639030@qq.com ``` > 单独获取一项配置 ```shell [root@supman ~]# git config --get user.name yong.yuan ``` ### 初始化仓库 > 创建一个文件夹,并初始化本地仓库,添加远程仓库 - `remote`远程、`origin`源头 ```shell [root@supman ~]# mkdir git [root@supman ~]# cd git [root@supman git]# git init Initialized empty Git repository in /root/git/.git/ [root@supman git]# git remote add origin https://gitee.com/codeyuany/git.git ``` > 在初始化仓库后我们会发现文件夹里什么都没有 ```shell [root@supman git]# ls ``` > 但是其实在文件夹里存在一个隐藏的`.git`文件 ```shell [root@supman git]# ls -al total 12 drwxr-xr-x 3 root root 4096 Aug 31 20:57 . dr-xr-x---. 9 root root 4096 Aug 31 20:56 .. drwxr-xr-x 7 root root 4096 Aug 31 20:57 .git ``` > 这个文件里面存在的是各种git的各种信息,删除这个`.git`文件后这个文件夹也就是个普通文件夹了 ```shell [root@supman git]# cd .git [root@supman .git]# ls branches config description HEAD hooks info objects refs ``` > 使用`git remote -v`可以看到本地仓库关联的远程仓库信息,就是我们刚才添加的远程仓库。 ```shell [root@supman .git]# git remote -vorigin https://gitee.com/codeyuany/git.git (fetch)origin https://gitee.com/codeyuany/git.git (push) ```