Git 全局设置(必须):

git config --global user.name "kenvie"
git config --global user.email "7097341@qq.com"

创建 git 仓库:

mkdir [folder]   //建立一个仓库(文件夹)
cd [folder]      //进入创建的这个仓库(文件夹)
git init         //初始化这个仓库(文件夹)

#修改或者添加文件
git add .
git commit -m first_commit
git remote add origin 项目git   //https://xxx.com/xxx/xxx.git 格式
git push -u origin master

已有仓库?

cd [folder]
git remote add origin 项目git   //https://xxx.com/xxx/xxx.git 格式
git push -u origin master

演示例子:

#1、在目录中git下vue-element-admin这个仓库,git下来会把源码放在以项目名命名的文件夹里
D:\Project>git clone https://gitee.com/kenvie/vue-element-admin.git
Cloning into 'vue-element-admin'...
remote: Enumerating objects: 11956, done.
remote: Counting objects: 100% (11956/11956), done.
remote: Compressing objects: 100% (3983/3983), done.
remote: Total 11956 (delta 7354), reused 11956 (delta 7354), pack-reused 0
Receiving objects: 100% (11956/11956), 15.06 MiB | 1.75 MiB/s, done.
Resolving deltas: 100% (7354/7354), done.

#2、进入这个项目地址
D:\Project>cd vue-element-admin

-----------------------在这中间可以添加、修改文件-----------------------

#3、这句我理解的意思就是将目录中的文件添加到暂存区
D:\Project\vue-element-admin>git add .

#4、将暂存区里的改动给提交到本地的版本库
D:\Project\vue-element-admin>git commit -m 修订README.md
[master 5746f0d] 修订README.md
 1 file changed, 1 insertion(+), 2 deletions(-)

#5、我理解的是关联远程git仓库
D:\Project\vue-element-admin>git remote add origin https://gitee.com/kenvie/vue-element-admin.git
fatal: remote origin already exists.

#6、同步本地和远程仓库
D:\Project\vue-element-admin>git push -u origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 310 bytes | 310.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/kenvie/vue-element-admin.git
   33a93a1..5746f0d  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

#查看提交记录
D:\Project\vue-element-admin>git log
commit 5746f0dcb1f9d8690a5200129cfa9ddfed26a9c2 (HEAD -> master, origin/master, origin/HEAD)
Author: kenvie <7097341@qq.com>              //提交的用户
Date:   Mon Apr 12 12:14:38 2021 +0800       //提交的时间

    <E4><BF><AE><E8><AE><A2>README.md
最后修改:2021 年 05 月 19 日
如果觉得我的文章对你有用,请随意赞赏