git的简单cmd使用

------------------------------------创建分支拉取和推送
asus@Chief MINGW64 ~
$ cd D:/东软H5/仓库

克隆项目(非常重要的一步)
asus@Chief MINGW64 /d/东软H5/仓库
$ git clone https://gitee.com/zeng-haoran/h5-training-warehouse.git
Cloning into ‘h5-training-warehouse‘...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 30 (delta 7), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (30/30), done.
Resolving deltas: 100% (7/7), done.

asus@Chief MINGW64 /d/东软H5/仓库
$ cd D:/东软H5/仓库/h5-training-warehouse

创建分支并跳转到分支上
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (master)
$ git checkout -b chief
Switched to a new branch ‘chief‘

推送本地分支到远端(上传分支)
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (chief)
$ git push origin chief
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
remote: Create a pull request for ‘chief‘ on Gitee by visiting:
remote: https://gitee.com/zeng-haoran/h5-training-warehouse/pull/new/zeng-haoran:chief...zeng-haoran:master
To https://gitee.com/zeng-haoran/h5-training-warehouse.git
* [new branch] chief -> chief

添加文件到git 缓存中
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (chief)
$ git add .

这个地方报错“不能没有提交的备注”
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (chief)
$ git commit -m ""
Aborting commit due to empty commit message.

提交保存的文件到本地分支上
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (chief)
$ git commit -m "3"
[chief 047bde1] 3
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 3.txt

本地分支与远端分支关联 并推送到远端分支上(联系过一次,就可以直接用git push推送了)
asus@Chief MINGW64 /d/东软H5/仓库/h5-training-warehouse (chief)
$ git push --set-upstream origin chief
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 208 bytes | 208.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/zeng-haoran/h5-training-warehouse.git
b06e3d1..047bde1 chief -> chief
Branch ‘chief‘ set up to track remote branch ‘chief‘ from ‘origin‘.

 

 

------------------------------------创建分支拉取和推送

C:\>d:

添加到git缓存
D:\东软H5\仓库\h5-training-warehouse>git add .

提交到本地分支中
D:\东软H5\仓库\h5-training-warehouse>git commit -m "xxxx"
[chief aecf5c3] xxxx
1 file changed, 1 insertion(+)

推送到远端分支
D:\东软H5\仓库\h5-training-warehouse>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 252 bytes | 252.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/zeng-haoran/h5-training-warehouse.git
047bde1..aecf5c3 chief -> chief


D:\东软H5\仓库\h5-training-warehouse>git status
On branch chief
Your branch is up to date with ‘origin/chief‘.

nothing to commit, working tree clean

切换到master主分支上
D:\东软H5\仓库\h5-training-warehouse>git checkout master
Switched to branch ‘master‘
Your branch is up to date with ‘origin/master‘.

合并自己的分支(相当于提交commit)
D:\东软H5\仓库\h5-training-warehouse>git merge chief
Updating b06e3d1..aecf5c3
Fast-forward
3.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 3.txt

推送到master远端
D:\东软H5\仓库\h5-training-warehouse>git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/zeng-haoran/h5-training-warehouse.git
b06e3d1..aecf5c3 master -> master

最后一定要跳转到自己的分支继续工作
D:\东软H5\仓库\h5-training-warehouse>git checkout chief
Switched to branch ‘chief‘
Your branch is up to date with ‘origin/chief‘.

 

git的简单cmd使用

上一篇:element-ui中的table可分页多选功能-记住上一页勾选数据、取消多选


下一篇:SignalR + KnockoutJS + ASP.NET MVC 实现井字游戏