一、需求
本地有一个微信小程序的项目源码,只是文件夹的形式,包括一些js和一些页面,想把这个文件夹用GitLab管理,于是就需要把本地文件夹push到服务器的GitLab上面
二、操作
2.1:本地文件夹下载远程的项目
在本地文件夹里面初始化git
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP
$ git init
Initialized empty Git repository in D:/SmallAPP/.git/
从远程的Git仓库pull项目下来
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$ git pull http://IP:3680/wangxuejing/SmallAPP.git master
remote: Counting objects: 28, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 28 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (28/28), done.
From http://IP:3680/wangxuejing/SmallAPP
* branch master -> FETCH_HEAD
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$ ls
app.js app.wxss project.config.json SmallAPP/
app.json pages/ README.md utils/
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$
2.2:本地文件夹提交更改到远程的项目
首先需要git status 查看更改信息,如下图所示说明有一个修改的文件,还有一个未跟踪的文件,这个时候我们就需要执行git add -A添加所有的文件到仓库
执行git add -A后再次查看git status 你会发现状态正常,一个是新增的,一个是修改的
接下来利用git commit -m '提交备注信息' 提交所有更改到本地仓库
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$ git commit -m '提交所有'
[master a46c80a] 鎻愪氦鎵€鏈▒
2 files changed, 1 insertion(+), 1 deletion(-)
delete mode 160000 SmallAPP
create mode 100644 test.txt
利用git push把本地内容提交到远程仓库
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$ git push http://IP:3680/wangxuejing/SmallAPP master
warning: redirecting to http://IP:3680/wangxuejing/SmallAPP.git/
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 324 bytes | 324.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To http://IP:3680/wangxuejing/SmallAPP
3735d44..a46c80a master -> master
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
需要注意的是如果是新增了一个空的文件夹,Git是监测不到的,我们如果在文件夹随便创建一个文件这个时候执行git status的话就可以监控到变化了,这个时候再依次执行
git add -A
git commit -m '提交到本地'
git push url master
就可以完成提交到远程仓库了,从远程同步更新执行git pull 命令即可,如下图所示
KING@DESKTOP-PAA9BSV MINGW64 /d/SmallAPP (master)
$ git pull http://IP:3680/wangxuejing/SmallAPP master
warning: redirecting to http://IP:3680/wangxuejing/SmallAPP.git/
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From http://IP:3680/wangxuejing/SmallAPP
* branch master -> FETCH_HEAD
Updating f09613d..7550040
Fast-forward
test/add | 1 +
1 file changed, 1 insertion(+)
create mode 100644 test/add