在windows克隆GitHub/GitLab远程项目,将本地代码推送到GitHub/GitLab远程仓库

目录

1、右击 Git Bash Here,进入windows的git操作页面

2、克隆GitLab远程项目到本地

3、切换路径到克隆的项目下

4、查看当前所有远程地址分支,默认在master分支下

5、切换到dev_Br20220610分支下

6、将代码打包到windows当前路线下

7、在windows上提交代码,添加到暂存区

8、添加日志信息,将代码提交到本地仓库

9、推送本地分支上的内容到远程仓库

10、如何将dev_Br20220610分支代码合并到master

11、从dev_Br20220610分支复制代码到新分支Odyssey-1.1.0


1、右击 Git Bash Here,进入windows的git操作页面

windows进入到D:\Git-Space\git-Odyssey目录下
右击 Git Bash Here,进入git操作页面。

2、克隆GitLab远程项目到本地

克隆前不用初始化,因为克隆会自动做初始化。第一次可能会提示绑定账号和密码,绑定对应的gitlab账号密码即可,如截图所示。

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey
$ git clone http://gitlab.com/bdop/bdopAutomatic.git
Cloning into 'bdopAutomatic'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
Resolving deltas: 100% (1/1), done.
在windows克隆GitHub/GitLab远程项目,将本地代码推送到GitHub/GitLab远程仓库_第1张图片 第一次初始化提示绑定github账号密码

3、切换路径到克隆的项目下

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey
$ ll
total 4
drwxr-xr-x 1 kele1210 1049089 0  6月 13 10:48 bdopAutomatic/

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey
$ cd bdopAutomatic/

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (master)
$ ll
total 2
-rw-r--r-- 1 kele1210 1049089 14  6月 13 10:48 README.md
-rw-r--r-- 1 kele1210 1049089 11  6月 13 10:48 ReleaseNote.txt

4、查看当前所有远程地址分支,默认在master分支下

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (master)
$ git branch -a
  dev_Br20220610
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev_Br20220610
  remotes/origin/master

5、切换到dev_Br20220610分支下

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (master)
$ git checkout dev_Br20220610
Switched to branch 'dev_Br20220610'
Your branch is up to date with 'origin/dev_Br20220610'.

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (dev_Br20220610)
$

6、将代码打包到windows当前路线下

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (dev_Br20220610)
$ ll
total 2
drwxr-xr-x 1 kele1210 1049089  0  6月 13 11:36 Odyssey-1.0.0/
-rw-r--r-- 1 kele1210 1049089 14  6月 13 10:48 README.md
-rw-r--r-- 1 kele1210 1049089 11  6月 13 10:48 ReleaseNote.txt

7、在windows上提交代码,添加到暂存区

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (dev_Br20220610)
$ git add Odyssey-1.0.0
warning: LF will be replaced by CRLF in Odyssey-1.0.0/alarm/re_alarm.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/alarm/send_alarm.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Elasticsearch/config/sample.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Elasticsearch/script/es_alive.sh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Elasticsearch/script/es_auto_start.sh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Kafka/config/conf.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Kafka/config/sample.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Kafka/logs/kafka_auto_start.bak.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Kafka/script/kafka_auto_start.sh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Zookeeper/config/conf.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Zookeeper/config/sample.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Zookeeper/logs/zk_auto_start.bak.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/component/Zookeeper/script/zk_auto_start.sh.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/dispatch/comp_conf.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/dispatch/dispatch.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/omanage/disp_conf.py.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in Odyssey-1.0.0/omanage/moni_log_del.sh.
The file will have its original line endings in your working directory

8、添加日志信息,将代码提交到本地仓库

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (dev_Br20220610)
$ git commit -m "第一次初始化Odyssey-1.0.0"
[dev_Br20220610 76b6e4f] 第一次初始化Odyssey-1.0.0
 21 files changed, 924 insertions(+)
 create mode 100644 Odyssey-1.0.0/alarm/re_alarm.py
 create mode 100644 Odyssey-1.0.0/alarm/re_alarm.pyc
 create mode 100644 Odyssey-1.0.0/alarm/send_alarm.py
 create mode 100644 Odyssey-1.0.0/alarm/send_alarm.pyc
 create mode 100644 Odyssey-1.0.0/component/Elasticsearch/config/conf
 create mode 100644 Odyssey-1.0.0/component/Elasticsearch/config/sample
 create mode 100644 Odyssey-1.0.0/component/Elasticsearch/script/es_alive.sh
 create mode 100644 Odyssey-1.0.0/component/Elasticsearch/script/es_auto_start.sh
 create mode 100644 Odyssey-1.0.0/component/Kafka/config/conf
 create mode 100644 Odyssey-1.0.0/component/Kafka/config/sample
 create mode 100644 Odyssey-1.0.0/component/Kafka/logs/kafka_auto_start.bak
 create mode 100644 Odyssey-1.0.0/component/Kafka/script/kafka_auto_start.sh
 create mode 100644 Odyssey-1.0.0/component/Zookeeper/config/conf
 create mode 100644 Odyssey-1.0.0/component/Zookeeper/config/sample
 create mode 100644 Odyssey-1.0.0/component/Zookeeper/logs/zk_auto_start.bak
 create mode 100644 Odyssey-1.0.0/component/Zookeeper/script/zk_auto_start.sh
 create mode 100644 Odyssey-1.0.0/dispatch/comp_conf
 create mode 100644 Odyssey-1.0.0/dispatch/dispatch.py
 create mode 100644 Odyssey-1.0.0/dispatch/last.time.dat
 create mode 100644 Odyssey-1.0.0/omanage/disp_conf.py
 create mode 100644 Odyssey-1.0.0/omanage/moni_log_del.sh

9、推送本地分支上的内容到远程仓库

kele1210@CNHQ-kele1210N MINGW64 /d/Git-Space/git-Odyssey/bdopAutomatic (dev_Br20220610)
$ git push
Enumerating objects: 40, done.
Counting objects: 100% (40/40), done.
Delta compression using up to 4 threads
Compressing objects: 100% (30/30), done.
Writing objects: 100% (39/39), 13.47 KiB | 599.00 KiB/s, done.
Total 39 (delta 2), reused 0 (delta 0), pack-reused 0
remote: reposName:bdopAutomatic groupName:bdop branchname:dev_Br20220610
remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
remote:                                  Dload  Upload   Total   Spent    Left  Speed
remote: 100     1  100     1    0     0     90      0 --:--:-- --:--:-- --:--:--    90
remote: Mon Jun 13 10:53:13 CST 2022 send suc
remote:
remote: To create a merge request for dev_Br20220610, visit:
remote:   http://gitlab.com/bdop/bdopAutomatic/-/merge_requests/new?merge_request%5Bsource_branch%5D=dev_Br20220610
remote:
To http://gitlab.com/bdop/bdopAutomatic.git
   f1e9cdc..76b6e4f  dev_Br20220610 -> dev_Br20220610

因为换电脑了,所以下面的操作截图有些地方不一样。不妨碍git命令执行

10、如何将dev_Br20220610分支代码合并到master

a.首先切换到master分支上

kele1210@CNHQ-kele1210N MINGW64 /f/代码空间/gitsapce/bdalarm/Odyssey-1.0.0 (dev_Br20220610)
$ git checkout master

b.将本地master代码,push到远程master上

kele1210@CNHQ-kele1210N MINGW64 /f/代码空间/gitsapce/bdalarm/Odyssey-1.0.0/dispatch (master)
$ git push origin master
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: reposName:bdopAutomatic groupName:bdop branchname:master
remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
remote:                                  Dload  Upload   Total   Spent    Left  Speed
remote: 100     1  100     1    0     0    111      0 --:--:-- --:--:-- --:--:--   111
remote: Mon Aug 29 10:05:32 CST 2022 send suc
To http://gitlab.com/bdop/bdopAutomatic.git
   f1e9cdc..533c25a  master -> master

11、从dev_Br20220610分支复制代码到新分支Odyssey-1.1.0

a、切换分支到dev_Br20220610分支上,并pull拉取最新代码

kele1210@CNHQ-kele1210N MINGW64 /f/代码空间/gitsapce/bdalarm (master)
$ git checkout dev_Br20220610
Switched to branch 'dev_Br20220610'

b、新建Odyssey-1.1.0分支

kele1210@CNHQ-kele1210N MINGW64 /f/代码空间/gitsapce/bdalarm/Odyssey-1.0.0/dispatch (master)
$ git checkout -b Odyssey-1.1.0
Switched to a new branch 'Odyssey-1.1.0'

c、将Odyssey-1.1.0分支的代码推送到远程服务器

kele1210@CNHQ-kele1210N MINGW64 /f/代码空间/gitsapce/bdalarm (Odyssey-1.1.0)
$ git push origin Odyssey-1.1.0
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: bdop : bdopAutomatic : Odyssey-1.1.0
remote:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
remote:                                  Dload  Upload   Total   Spent    Left  Speed
remote: 100    63    0    63    0     0   7875      0 --:--:-- --:--:-- --:--:--  7875
remote: {"resultCode":"0","message":"Executed successful!","data":null}
remote: Mon Aug 29 11:45:47 CST 2022 {"resultCode":"0","message":"Executed successful!","data":null}
remote:
remote: To create a merge request for Odyssey-1.1.0, visit:
remote:   http://gitlab.com/bdop/bdopAutomatic/-/merge_requests/new?merge_request%5Bsource_branch%5D=Odyssey-1.1.0
remote:
To http://ggitlab.com/bdop/bdopAutomatic.git
 * [new branch]      Odyssey-1.1.0 -> Odyssey-1.1.0

你可能感兴趣的:(大数据运维工作经验,git,github)