项目开发代码提交(Chapter 4)
来自CloudWiki
创建分支
查看当前分支
thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v1.0) $ git status On branch mmall_v1.0 Untracked files: (use "git add <file>..." to include in what will be committed) package-lock.json package.json src/ webpack.config.js
创建并切换分支
thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.0) $ git checkout -b mmall_v4.11 Switched to a new branch 'mmall_v4.11' thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.11) $ git branch master mmall_v1.0 mmall_v4.0 * mmall_v4.11
提交分支到远程
查看分支状态
$ git status
On branch mmall_v4.11 Untracked files: (use "git add <file>..." to include in what will be committed) package-lock.json package.json src/ webpack.config.js nothing added to commit but untracked files present (use "git add" to track)
将改动提交给本地代码库
thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.11) $ git add . warning: LF will be replaced by CRLF in package-lock.json. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in package.json. The file will have its original line endings in your working directory. thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.11) $ git commit -am "chapter 4" [mmall_v4.11 fd4ea47] chapter 4 32 files changed, 5915 insertions(+) create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/image/icon/loading.gif ...
git commit 主要是将暂存区里的改动给提交到本地的版本库。
-m 参数表示可以直接输入后面的“message”
-a参数可以将所有已跟踪文件中的执行修改或删除操作的文件都提交到本地仓库,即使它们没有经过git add添加到暂存区.
将代码提交到远程
thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.11) $ git push fatal: The current branch mmall_v4.11 has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin mmall_v4.11 thinkpad@DESKTOP-LN2H42N MINGW64 ~/mmall - v4.11/doc/mmall-fe (mmall_v4.11) $ git push --set-upstream origin mmall_v4.11 Counting objects: 50, done. Delta compression using up to 4 threads. Compressing objects: 100% (42/42), done. Writing objects: 100% (50/50), 73.68 KiB | 1.05 MiB/s, done. Total 50 (delta 1), reused 0 (delta 0) remote: Powered By Gitee.com To gitee.com:happymmall_shangzhi/mmall_fe.git * [new branch] mmall_v4.11 -> mmall_v4.11 Branch mmall_v4.11 set up to track remote branch mmall_v4.11 from origin.
查看分支提交情况
在码云上查看分支提交情况: