您现在的位置是:首页 >其他 >使用rebase进行多人协作开发网站首页其他

使用rebase进行多人协作开发

zsx_yiyiyi 2024-06-17 10:48:24
简介使用rebase进行多人协作开发

使用rebase进行多人协作开发

1、master分支准备

# master分支
cd um
git init 

touch a.txt
git add a.txt
git commit -m "add a.txt"

touch b.txt
git add b.txt
git commit -m "add b.txt"

touch c.txt
git add c.txt
git commit -m "add c.txt"

touch d.txt
git add d.txt
git commit -m "add d.txt"

touch e.txt
git add e.txt
git commit -m "add e.txt"

touch f.txt
git add f.txt
git commit -m "add f.txt"

git remote add origin https://gitee.com/zsx242030/um.git
git push -u origin "master"

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

2、A、B、C三个用户拉取代码并切换分支

$ git clone https://gitee.com/zsx242030/um.git

$ cd um

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git checkout -b branch_a
Switched to a new branch 'branch_a'

$ git branch -a
* branch_a
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ git clone https://gitee.com/zsx242030/um.git

$ cd um

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git checkout -b branch_b
Switched to a new branch 'branch_b'

$ git branch -a
* branch_b
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ git clone https://gitee.com/zsx242030/um.git

$ cd um

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git checkout -b branch_c
Switched to a new branch 'branch_c'

$ git branch -a
* branch_c
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

3、A用户添加文件和修改文件

# branch_a分支操作
$ echo branch_a > a.txt

$ echo branch_a_new > new.txt

$ git add .

$ git commit -m "branch_a | update a.txt | add new.txt"
[branch_a b9709d6] branch_a | update a.txt | add new.txt
 2 files changed, 2 insertions(+)
 create mode 100644 new.txt

# 从分支上拉取
# 拉取的是两个分支都没有提交过的
$ git fetch origin

$ git rebase origin/master
Current branch branch_a is up to date.

$ git push origin branch_a:branch_a
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 340 bytes | 340.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_a' on Gitee by visiting:
remote:     https://gitee.com/zsx242030/um/pull/new/zsx242030:branch_a...zsx242030:master
To https://gitee.com/zsx242030/um.git
 * [new branch]      branch_a -> branch_a
 
$ git log --pretty=format:"%h: %cd %s" --graph
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

4、A用户的分支合并到master分支

# branch_a分支操作
$ git checkout branch_a
Already on 'branch_a'

# 合并
# 期间可能会存在下面的问题:
# 当您解决了此问题后,执行 "git rebase --continue"。
# 如果您想跳过此补丁,则执行 "git rebase --skip"。
# 要恢复原分支并停止变基,执行 "git rebase --abort"。
$ git rebase origin/master
Current branch branch_a is up to date.

$ git push origin branch_a:master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/um.git
   105370e..b9709d6  branch_a -> master
# 切换到master分支查看提交情况
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git pull
Updating 105370e..b9709d6
Fast-forward
 a.txt   | 1 +
 new.txt | 1 +
 2 files changed, 2 insertions(+)
 create mode 100644 new.txt

$ git log --pretty=format:"%h: %cd %s" --graph
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

5、B用户添加文件和修改文件

# branch_b分支操作
$ echo branch_b > a.txt

$ echo branch_b_new > new.txt

$ git status
On branch branch_b
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   a.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        new.txt

no changes added to commit (use "git add" and/or "git commit -a")

下面将进行拉取远程代码,拉取远程代码之前需要保证代码是 commit 的或者是 stash的。

4.1 stash

$ git stash
warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directory.
Saved working directory and index state WIP on branch_b: 105370e add f.txt
$ git fetch origin
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://gitee.com/zsx242030/um
 * [new branch]      branch_a   -> origin/branch_a
   105370e..b9709d6  master     -> origin/master
# 由于这里也添加了new.txt,所以会产生冲突,必须删除
$ git rebase origin/master
First, rewinding head to replay your work on top of it...
error: The following untracked working tree files would be overwritten by checkout:
        new.txt
Please move or remove them before you switch branches.
Aborting
could not detach HEAD

$ rm -f new.txt
# 重新拉取
$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded branch_b to origin/master.
# 查看拉取的情况
$ cat a.txt
branch_a

$ cat new.txt
branch_a_new
# 发现内容都是用户A提交的

$ git log --pretty=format:"%h: %cd %s" --graph
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt
# 下面弹出工作
# a.txt也添加了内容有冲突需要解决
$ git stash pop
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt

# a.txt的内容
<<<<<<< Updated upstream
branch_a
=======
branch_b
>>>>>>> Stashed changes

# 解决之后的内容
branch_a
branch_b

# 然后在new.txt中添加内容
echo branch_b_new >> new.txt
$ git status
On branch branch_b
Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        both modified:   a.txt

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   new.txt

no changes added to commit (use "git add" and/or "git commit -a")
# 添加文件提交
$ git add .

$ git commit -m "branch_b | update a.txt | update new.txt"
[branch_b fbcb7dd] branch_b | update a.txt | update new.txt
 2 files changed, 2 insertions(+)

$ git push origin branch_b:branch_b
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 344 bytes | 344.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_b' on Gitee by visiting:
remote:     https://gitee.com/zsx242030/um/pull/new/zsx242030:branch_b...zsx242030:master
To https://gitee.com/zsx242030/um.git
 * [new branch]      branch_b -> branch_b

4.2 commit

$ git add .
warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in new.txt.
The file will have its original line endings in your working directory.

$ git commit -m "branch_b | update a.txt | add new.txt"
[branch_b 0125545] branch_b | update a.txt | add new.txt
 2 files changed, 2 insertions(+)
 create mode 100644 new.txt
 
# 从分支上拉取
# 拉取的是两个分支都没有提交过的
$ git fetch origin
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://gitee.com/zsx242030/um
 * [new branch]      branch_a   -> origin/branch_a
   105370e..b9709d6  master     -> origin/master

# 这里有冲关系需要解决冲突
$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: branch_b | update a.txt | add new.txt
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M       a.txt
Falling back to patching base and 3-way merge...
Auto-merging new.txt
CONFLICT (add/add): Merge conflict in new.txt
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
Patch failed at 0001 branch_b | update a.txt | add new.txt
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

# 解决冲突
$ cat a.txt
<<<<<<< HEAD
branch_a
=======
branch_b
>>>>>>> branch_b | update a.txt | add new.txt

$ cat new.txt
<<<<<<< HEAD
branch_a_new
=======
branch_b_new
>>>>>>> branch_b | update a.txt | add new.txt


# 解决
$ cat a.txt
branch_a
branch_b

$ cat new.txt
branch_a_new
branch_b_new
# 继续rebase
# 直接运行这个会报错
$ git rebase --continue
a.txt: needs merge
new.txt: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

# 需要先添加
$ git add a.txt new.txt

$ git rebase --continue
Applying: branch_b | update a.txt | add new.txt
# push
$ git push origin branch_b:branch_b
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 345 bytes | 345.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_b' on Gitee by visiting:
remote:     https://gitee.com/zsx242030/um/pull/new/zsx242030:branch_b...zsx242030:master
To https://gitee.com/zsx242030/um.git
 * [new branch]      branch_b -> branch_b

$ git log --pretty=format:"%h: %cd %s" --graph
* b1786d3: Thu May 18 22:04:56 2023 +0800 branch_b | update a.txt | add new.txt
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

6、B用户的分支合并到master分支

# branch_b分支操作
$ git checkout branch_b
Already on 'branch_b'

# 合并
# 期间可能会存在下面的问题:
# 当您解决了此问题后,执行 "git rebase --continue"。
# 如果您想跳过此补丁,则执行 "git rebase --skip"。
# 要恢复原分支并停止变基,执行 "git rebase --abort"。
$ git rebase origin/master
Current branch branch_b is up to date.

$ git push origin branch_b:master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/um.git
   b9709d6..b1786d3  branch_b -> master
# 切换到master分支查看提交情况
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git pull
Updating 105370e..b1786d3
Fast-forward
 a.txt   | 2 ++
 new.txt | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100644 new.txt

$ git log --pretty=format:"%h: %cd %s" --graph
* b1786d3: Thu May 18 22:04:56 2023 +0800 branch_b | update a.txt | add new.txt
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

7、C用户删除文件和修改文件

# branch_c分支操作
$ echo branch_c > a.txt

$ rm -f e.txt

$ git status
On branch branch_c
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   a.txt
        deleted:    e.txt

no changes added to commit (use "git add" and/or "git commit -a")

7.1 stash

$ git stash
warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directory.
Saved working directory and index state WIP on branch_c: 105370e add f.txt

$ git fetch origin
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
From https://gitee.com/zsx242030/um
 * [new branch]      branch_a   -> origin/branch_a
 * [new branch]      branch_b   -> origin/branch_b
   105370e..b1786d3  master     -> origin/master

$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Fast-forwarded branch_c to origin/master.

$ git stash pop
Removing e.txt
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt

$ cat a.txt
<<<<<<< Updated upstream
branch_a
branch_b
=======
branch_c
>>>>>>> Stashed changes

# 解决冲突
$ cat a.txt
branch_a
branch_b
branch_c

$ git add .

$ git commit -m "branch_c | update a.txt | delete e.txt"
[branch_c de4d548] branch_c | update a.txt | delete e.txt
 2 files changed, 2 insertions(+), 1 deletion(-)
 delete mode 100644 e.txt

$ git push origin branch_c:branch_c
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 298 bytes | 298.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_c' on Gitee by visiting:
remote:     https://gitee.com/zsx242030/um/pull/new/zsx242030:branch_c...zsx242030:master
To https://gitee.com/zsx242030/um.git
 * [new branch]      branch_c -> branch_c

7.2 commit

$ git add .
warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directory.

$ git commit -m "branch_c | update a.txt | delete e.txt"
[branch_c 095aecb] branch_c | update a.txt | delete e.txt
 2 files changed, 1 insertion(+)
 delete mode 100644 e.txt
$ git fetch origin
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
From https://gitee.com/zsx242030/um
 * [new branch]      branch_a   -> origin/branch_a
 * [new branch]      branch_b   -> origin/branch_b
   105370e..b1786d3  master     -> origin/master

$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: branch_c | update a.txt | delete e.txt
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M       a.txt
Falling back to patching base and 3-way merge...
Removing e.txt
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
Patch failed at 0001 branch_c | update a.txt | delete e.txt
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
# 解决冲突
$ cat a.txt
<<<<<<< HEAD
branch_a
branch_b
=======
branch_c
>>>>>>> branch_c | update a.txt | delete e.txt

$ cat a.txt
branch_a
branch_b
branch_c
$ git add .

$ git rebase --continue
Applying: branch_c | update a.txt | delete e.txt
$ git push origin branch_c:branch_c
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 301 bytes | 301.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_c' on Gitee by visiting:
remote:     https://gitee.com/zsx242030/um/pull/new/zsx242030:branch_c...zsx242030:master
To https://gitee.com/zsx242030/um.git
 * [new branch]      branch_c -> branch_c

9、C用户的分支合并到master分支

# branch_c分支操作
$ git checkout branch_c
Already on 'branch_c'

# 合并
# 期间可能会存在下面的问题:
# 当您解决了此问题后,执行 "git rebase --continue"。
# 如果您想跳过此补丁,则执行 "git rebase --skip"。
# 要恢复原分支并停止变基,执行 "git rebase --abort"。
$ git rebase origin/master
Current branch branch_c is up to date.

$ git push origin branch_c:master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/um.git
   b1786d3..9fb14a6  branch_c -> master
# 切换到master分支查看提交情况
$ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

$ git log --pretty=format:"%h: %cd %s" --graph
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git pull
Updating 105370e..9fb14a6
Fast-forward
 a.txt   | 3 +++
 e.txt   | 0
 new.txt | 2 ++
 3 files changed, 5 insertions(+)
 delete mode 100644 e.txt
 create mode 100644 new.txt

$ git log --pretty=format:"%h: %cd %s" --graph
* 9fb14a6: Thu May 18 22:26:08 2023 +0800 branch_c | update a.txt | delete e.txt
* b1786d3: Thu May 18 22:04:56 2023 +0800 branch_b | update a.txt | add new.txt
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

8、本地分支修改完直接提交到远程分支

$ git clone https://gitee.com/zsx242030/um.git

$ cd um

$ git log --pretty=format:"%h: %cd %s" --graph
* 9fb14a6: Thu May 18 22:26:08 2023 +0800 branch_c | update a.txt | delete e.txt
* b1786d3: Thu May 18 22:04:56 2023 +0800 branch_b | update a.txt | add new.txt
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt

$ git checkout -b develop
Switched to a new branch 'develop'

$ git branch -a
* develop
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/branch_a
  remotes/origin/branch_b
  remotes/origin/branch_c
  remotes/origin/master
# 新建文件
$ echo test > test.txt

$ git add .
warning: LF will be replaced by CRLF in test.txt.
The file will have its original line endings in your working directory.

$ git commit -m "develop | add test.txt"
[develop 40f466a] develop | add test.txt
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt

$ git fetch origin

$ git rebase origin/master
Current branch develop is up to date.

$ git push origin develop:master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 279 bytes | 279.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/um.git
   9fb14a6..40f466a  develop -> master
   
$ git log --pretty=format:"%h: %cd %s" --graph
* 40f466a: Thu May 18 22:34:08 2023 +0800 develop | add test.txt
* 9fb14a6: Thu May 18 22:26:08 2023 +0800 branch_c | update a.txt | delete e.txt
* b1786d3: Thu May 18 22:04:56 2023 +0800 branch_b | update a.txt | add new.txt
* b9709d6: Thu May 18 20:36:54 2023 +0800 branch_a | update a.txt | add new.txt
* 105370e: Wed May 17 22:01:32 2023 +0800 add f.txt
* 46409d9: Wed May 17 22:01:31 2023 +0800 add e.txt
* 082352c: Wed May 17 22:01:31 2023 +0800 add d.txt
* d8f4266: Wed May 17 22:01:30 2023 +0800 add c.txt
* a5e5961: Wed May 17 22:01:30 2023 +0800 add b.txt
* 4db21f4: Wed May 17 22:01:29 2023 +0800 add a.txt
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。