File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change 5454
5555- [ Gitlab] ( )
5656 - [ 安装] ( other/gitlab/gitlab_install.md )
57+ - [ Git 克隆 master 分支后将修改推送 dev 分支] ( other/gitlab/gitmaster-todev.md )
5758
5859- [ Helm] ( )
5960 - [ helm 使用] ( kubernetes/helm_use.md )
Original file line number Diff line number Diff line change 1+ # master 分支修改推送至 dev 分支
2+
3+ - 本意是修改 dev 分支的 code,修改完成后,发现 clone 错了分支,于是才会有后面的步骤
4+
5+ 你可以按照以下步骤操作:
6+
7+ 1 . ** 确认当前分支** (你可能在 ` main ` 或 ` master ` ):
8+
9+ ``` bash
10+ git branch
11+ ```
12+
13+ 如果当前在 ` main ` ,你需要切换到 ` dev ` 。
14+
15+ 2 . ** 切换到 ` dev ` 分支** (如果本地没有 ` dev ` 分支,需要先创建并追踪远程分支):
16+
17+ ``` bash
18+ git checkout -b dev origin/dev
19+ ```
20+
21+ 或者,如果本地已有 ` dev ` 分支:
22+
23+ ``` bash
24+ git checkout dev
25+ git pull origin dev # 确保是最新的
26+ ```
27+
28+ 3 . ** 将修改从 ` main ` 复制到 ` dev ` ** : 如果你的修改已经提交,但还在 ` main ` 分支,可以使用 ` cherry-pick ` :# 我的还没 commit,直接后的后面的步骤
29+
30+ ``` bash
31+ git checkout dev
32+ git cherry-pick < commit-id>
33+ ```
34+
35+ 或者如果你还没有 commit,直接用 ` stash ` 临时保存后切换:
36+
37+ ``` bash
38+ git stash
39+ git checkout dev
40+ git stash pop
41+ ```
42+
43+ 4 . ** 推送到远程 ` dev ` 分支** :
44+
45+ ``` bash
46+ git add .
47+ git commit -m " 你的提交信息"
48+ git push origin dev
49+ ```
50+
51+ 这样,你的修改就被提交到 ` dev ` 分支,而不会影响 ` main ` 分支。
You can’t perform that action at this time.
0 commit comments