Git基本操作——将本地项目同步到远程仓库
- 安装Git【Windows版】:https://gitforwindows.org/ 或 https://git-scm.com/download/win
- 码云新建用户和仓库,https://gitee.com/,复制仓库链接
3.进入小程序项目的根目录:如,D:\Java\order-mini-app,右键git bash,进入命令行
huawei@yanni matebook MINGW64 /d/Java/order-mini-app
$ git init
Initialized empty Git repository in D:/Java/order-mini-app/.git/
huawei@yanni matebook MINGW64 /d/Java/order-mini-app
$ git config --global user.name "tenneling"
huawei@yanni matebook MINGW64 /d/Java/order-mini-app
$ git config --global user.email "tenneling@163.com"
huawei@yanni matebook MINGW64 /d/Java/order-mini-app
$ git config --global --add safe.directory D:/Java/order-mini-app
huawei@yanni matebook MINGW64 /d/Java/order-mini-app (master)
$ git remote add origin https://gitee.com/tenneling/order-mini-app.git
huawei@yanni matebook MINGW64 /d/Java/order-mini-app (master)
$ git add .
warning: in the working copy of '.eslintrc.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'app.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'app.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'app.wxss', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/index/index.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/index/index.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/index/index.wxml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/index/index.wxss', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/logs/logs.js', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/logs/logs.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/logs/logs.wxml', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'pages/logs/logs.wxss', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'sitemap.json', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'utils/util.js', LF will be replaced by CRLF the next time Git touches it
huawei@yanni matebook MINGW64 /d/Java/order-mini-app (master)
$ git commit -m "Initial commit"
[master (root-commit) 9783ef2] Initial commit
16 files changed, 322 insertions(+)
create mode 100644 .eslintrc.js
create mode 100644 app.js
create mode 100644 app.json
create mode 100644 app.wxss
create mode 100644 pages/index/index.js
create mode 100644 pages/index/index.json
create mode 100644 pages/index/index.wxml
create mode 100644 pages/index/index.wxss
create mode 100644 pages/logs/logs.js
create mode 100644 pages/logs/logs.json
create mode 100644 pages/logs/logs.wxml
create mode 100644 pages/logs/logs.wxss
create mode 100644 project.config.json
create mode 100644 project.private.config.json
create mode 100644 sitemap.json
create mode 100644 utils/util.js
huawei@yanni matebook MINGW64 /d/Java/order-mini-app (master)
$ git push -u origin master
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
Enumerating objects: 21, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 8 threads
Compressing objects: 100% (19/19), done.
Writing objects: 100% (21/21), 4.91 KiB | 387.00 KiB/s, done.
Total 21 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/tenneling/order-mini-app.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
上传完成后,码云上也同步成功了
Git的常用命令
- git clone url:把origin master上的项目克隆到本地
- git add 文件名:向Git添加文件
- git add -A:向Git添加所有文件
- git commit -m “message”:向Git提交。-m是输入信息参数,双引号内是备注信息内容
- git push:向远程Git进行push操作,push到远程同名分支
- git push origin master:向远程主干进行push操作,push到远程主干
- git status:查看本地分支以及当前的本地文件状态(是否提交到远程)
- git pull:获取文件(默认从当前分支)
- git merge 分支名:合并代码
- git fetch:首先通过命令更新分支
- git branch -a:查看本地分支和远程分支,带星号绿色的为当前所在分支
- git checkout -b branch2 origin/master:以master为基础创建新的本地分支branch2
- git checkout -b branch2 origin/master -b:创建branch2分支后,自动切换到新的分支
- git push origin branch2:创建完成本地branch2分支之后,将本地新分支推送到远程branch2分支上
【常用,但不适用于码云】快速浏览Git项目的方法:
在浏览器网址部分中的“github”后边,添加一个“1s”
示例:https://github.com/2YSP/rpc-spring-boot-starter --> https://github1s.com/2YSP/rpc-spring-boot-starter