您现在的位置是:首页 >技术交流 >使用pull和merge进行多人协作开发网站首页技术交流
使用pull和merge进行多人协作开发
简介使用pull和merge进行多人协作开发
使用pull和merge进行多人协作开发
1、master分支准备
# master分支
$ cd tm
$ 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/sm.git
$ git push -u origin "master"
Counting objects: 13, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (13/13), 1.04 KiB | 1.04 MiB/s, done.
Total 13 (delta 4), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/sm.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
$ git log --pretty=format:"%h: %cd %s" --graph
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 2023 +0800 add a.txt
2、A、B、C三个用户拉取代码并切换分支
# A用户branch_a分支
$ git clone https://gitee.com/zsx242030/sm.git
$ cd sm
$ git log --pretty=format:"%h: %cd %s" --graph
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 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
# B用户branch_b分支
$ git clone https://gitee.com/zsx242030/sm.git
$ cd sm
$ git log --pretty=format:"%h: %cd %s" --graph
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 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
# C用户branch_c分支
$ git clone https://gitee.com/zsx242030/sm.git
$ cd sm
$ git log --pretty=format:"%h: %cd %s" --graph
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 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
# 暂存,防止pull的时候本地修改的代码被覆盖
$ git stash -u
warning: LF will be replaced by CRLF in new.txt.
The file will have its original line endings in your working directory.
Saved working directory and index state WIP on branch_a: 87d5c63 add f.txt
$ git status
On branch branch_a
nothing to commit, working tree clean
# 拉取远程master分支的代码
$ git pull origin master
From https://gitee.com/zsx242030/sm
* branch master -> FETCH_HEAD
Already up-to-date.
# 弹出修改的内容
$ git stash pop
On branch branch_a
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")
Dropped refs/stash@{0} (951c49aaff0154395bdd840a85796323392cb1ac)
$ git status
On branch branch_a
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")
$ git add .
$ git commit -m "branch_a | update a.txt | add new.txt"
[branch_a ddbfc0b] branch_a | update a.txt | add new.txt
2 files changed, 2 insertions(+)
create mode 100644 new.txt
$ 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), 341 bytes | 341.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/sm/pull/new/zsx242030:branch_a...zsx242030:master
To https://gitee.com/zsx242030/sm.git
* [new branch] branch_a -> branch_a
$ git log --pretty=format:"%h: %cd %s" --graph
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 2023 +0800 add a.txt
4、A用户的分支合并到master分支
# 有的公司使用的是gitlab只需要在上面进行mr操作即可
# 有的需要在本地合并然后推送到主分支
# master分支操作
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
# 合并
$ git merge origin/branch_a
$ git merge branch_a
Updating 87d5c63..ddbfc0b
Fast-forward
a.txt | 1 +
new.txt | 1 +
2 files changed, 2 insertions(+)
create mode 100644 new.txt
# 推送
$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/sm.git
87d5c63..ddbfc0b master -> master
$ git log --pretty=format:"%h: %cd %s" --graph
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 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")
# 暂存
$ 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: 87d5c63 add f.txt
$ git status
On branch branch_b
Untracked files:
(use "git add <file>..." to include in what will be committed)
new.txt
nothing added to commit but untracked files present (use "git add" to track)
# 拉取远程master分支的代码
$ git pull origin master
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/sm
* branch master -> FETCH_HEAD
87d5c63..ddbfc0b master -> origin/master
error: The following untracked working tree files would be overwritten by merge:
new.txt
Please move or remove them before you merge.
Aborting
Updating 87d5c63..ddbfc0b
# 这里是由于该分支新增了new.txt文件,而master分支上用户A也新增了new.txt文件
# 这里我们修改new.txt文件的名字
$ mv new.txt new.bak
$ ls
a.txt b.txt c.txt d.txt e.txt f.txt new.bak
# 重新拉取代码
$ git pull origin master
From https://gitee.com/zsx242030/sm
* branch master -> FETCH_HEAD
Updating 87d5c63..ddbfc0b
Fast-forward
a.txt | 1 +
new.txt | 1 +
2 files changed, 2 insertions(+)
create mode 100644 new.txt
$ ls
a.txt b.txt c.txt d.txt e.txt f.txt new.bak new.txt
$ cat a.txt
branch_a
$ cat new.txt
branch_a_new
$ cat new.bak
branch_b_new
# 弹出修改的内容
$ git stash pop
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
# 查看冲突
$ cat a.txt
<<<<<<< Updated upstream
branch_a
=======
branch_b
>>>>>>> Stashed changes
# 解决冲突
$ cat a.txt
branch_a
branch_b
# 我们将new.bak和new.txt的文件进行合并,然后删除new.bak
$ cat new.txt
branch_a_new
branch_b_new
$ 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 | add new.txt"
[branch_b 5b05cb6] branch_b | update a.txt | add 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), 348 bytes | 348.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/sm/pull/new/zsx242030:branch_b...zsx242030:master
To https://gitee.com/zsx242030/sm.git
* [new branch] branch_b -> branch_b
$ git log --pretty=format:"%h: %cd %s" --graph
* 5b05cb6: Sat May 27 13:17:12 2023 +0800 branch_b | update a.txt | add new.txt
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 2023 +0800 add a.txt
6、B用户的分支合并到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 merge origin/branch_b
$ git merge branch_b
Updating 87d5c63..5b05cb6
Fast-forward
a.txt | 2 ++
new.txt | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 new.txt
# 推送
$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/sm.git
ddbfc0b..5b05cb6 master -> master
$ git log --pretty=format:"%h: %cd %s" --graph
* 5b05cb6: Sat May 27 13:17:12 2023 +0800 branch_b | update a.txt | add new.txt
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 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")
# 暂存
$ 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: 87d5c63 add f.txt
$ git status
On branch branch_c
nothing to commit, working tree clean
# 拉取远程master分支的代码
$ git pull origin master
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/sm
* branch master -> FETCH_HEAD
87d5c63..5b05cb6 master -> origin/master
Updating 87d5c63..5b05cb6
Fast-forward
a.txt | 2 ++
new.txt | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 new.txt
# 弹出暂存
$ 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 status
On branch branch_c
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: e.txt
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: a.txt
$ git add .
$ git commit -m "branch_c | update a.txt | delete e.txt"
[branch_c 8cb57f6] 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/sm/pull/new/zsx242030:branch_c...zsx242030:master
To https://gitee.com/zsx242030/sm.git
* [new branch] branch_c -> branch_c
9、C用户的分支合并到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 merge origin/branch_c
$ git merge branch_c
Updating 87d5c63..8cb57f6
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 push origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/sm.git
5b05cb6..8cb57f6 master -> master
$ git log --pretty=format:"%h: %cd %s" --graph
* 8cb57f6: Sat May 27 13:31:13 2023 +0800 branch_c | update a.txt | delete e.txt
* 5b05cb6: Sat May 27 13:17:12 2023 +0800 branch_b | update a.txt | add new.txt
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 2023 +0800 add a.txt
10、使用commit代替stash解决pull时的代码覆盖
我们从 branch_a 分支上拉取 branch_d 分支:
$ git checkout -b branch_d origin/branch_a
Switched to a new branch 'branch_d'
Branch branch_d set up to track remote branch branch_a from origin.
$ git log --oneline
ddbfc0b (HEAD -> branch_d, origin/branch_a) branch_a | update a.txt | add new.txt
87d5c63 add f.txt
47e8b59 add e.txt
c0547da add d.txt
9c173bb add c.txt
8c4a625 add b.txt
8e58180 add a.txt
$ ls
a.txt b.txt c.txt d.txt e.txt f.txt new.txt
修改 a.txt 和 e.txt 文件,删除 b.txt 文件:
echo branch_d > a.txt
echo branch_d > e.txt
rm b.txt
$ git status
On branch branch_d
Your branch is up-to-date with 'origin/branch_a'.
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: b.txt
modified: e.txt
no changes added to commit (use "git add" and/or "git commit -a")
# 提交
$ git add .
$ git commit -m "branch_d | update a.txt | update b.txt | update e.txt"
[branch_d 75dc0b6] branch_d | update a.txt | update b.txt | update e.txt
3 files changed, 2 insertions(+), 1 deletion(-)
delete mode 100644 b.txt
# pull远程分支
$ git pull origin master
From https://gitee.com/zsx242030/sm
* branch master -> FETCH_HEAD
CONFLICT (modify/delete): e.txt deleted in 8cb57f667e7681be447d98051da7a3b5123f8c33 and modified in HEAD. Version HEAD of e.txt left in tree.
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
Automatic merge failed; fix conflicts and then commit the result.
# 冲突
$ cat a.txt
<<<<<<< HEAD
branch_d
=======
branch_a
branch_b
branch_c
>>>>>>> 8cb57f667e7681be447d98051da7a3b5123f8c33
# 解决冲突
$ cat a.txt
branch_a
branch_b
branch_c
branch_d
$ git status
On branch branch_d
Your branch is ahead of 'origin/branch_a' by 1 commit.
(use "git push" to publish your local commits)
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Changes to be committed:
modified: new.txt
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
both modified: a.txt
deleted by them: e.txt
$ git add .
warning: LF will be replaced by CRLF in e.txt.
The file will have its original line endings in your working directory.
$ git status
On branch branch_d
Your branch is ahead of 'origin/branch_a' by 1 commit.
(use "git push" to publish your local commits)
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
modified: a.txt
modified: new.txt
$ git commit -m "branch_d | update a.txt | update b.txt | update e.txt"
[branch_d 7b923b2] branch_d | update a.txt | update b.txt | update e.txt
$ git status
On branch branch_d
Your branch is ahead of 'origin/branch_a' by 4 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git log --oneline
7b923b2 (HEAD -> branch_d) branch_d | update a.txt | update b.txt | update e.txt
75dc0b6 branch_d | update a.txt | update b.txt | update e.txt
8cb57f6 (origin/master, origin/branch_c, origin/HEAD, master) branch_c | update a.txt | delete e.txt
5b05cb6 (origin/branch_b) branch_b | update a.txt | add new.txt
ddbfc0b (origin/branch_a) branch_a | update a.txt | add new.txt
87d5c63 add f.txt
47e8b59 add e.txt
c0547da add d.txt
9c173bb add c.txt
8c4a625 add b.txt
8e58180 add a.txt
# 合并commit
$ git rebase -i 8cb57f6
error: could not apply 75dc0b6... branch_d | update a.txt | update b.txt | update e.txt
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".
Could not apply 75dc0b6... branch_d | update a.txt | update b.txt | update e.txt
CONFLICT (modify/delete): e.txt deleted in HEAD and modified in 75dc0b6... branch_d | update a.txt | update b.txt | update e.txt. Version 75dc0b6... branch_d | update a.txt | update b.txt | update e.txt of e.txt left in tree.
Removing b.txt
Auto-merging a.txt
CONFLICT (content): Merge conflict in a.txt
# 冲突
$ cat a.txt
<<<<<<< HEAD
branch_a
branch_b
branch_c
=======
branch_d
>>>>>>> 75dc0b6... branch_d | update a.txt | update b.txt | update e.txt
# 解决冲突
$ cat a.txt
branch_a
branch_b
branch_c
branch_d
$ git add .
$ git rebase --continue
[detached HEAD d735ee3] branch_d | update a.txt | update b.txt | update e.txt
3 files changed, 3 insertions(+), 1 deletion(-)
delete mode 100644 b.txt
create mode 100644 e.txt
Successfully rebased and updated refs/heads/branch_d.
$ git status
On branch branch_d
Your branch is ahead of 'origin/branch_a' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git log --oneline
d735ee3 (HEAD -> branch_d) branch_d | update a.txt | update b.txt | update e.txt
8cb57f6 (origin/master, origin/branch_c, origin/HEAD, master) branch_c | update a.txt | delete e.txt
5b05cb6 (origin/branch_b) branch_b | update a.txt | add new.txt
ddbfc0b (origin/branch_a) branch_a | update a.txt | add new.txt
87d5c63 add f.txt
47e8b59 add e.txt
c0547da add d.txt
9c173bb add c.txt
8c4a625 add b.txt
8e58180 add a.txt
# 推送到远程
$ git push origin branch_d:branch_d
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (4/4), 379 bytes | 379.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
remote: Create a pull request for 'branch_d' on Gitee by visiting:
remote: https://gitee.com/zsx242030/sm/pull/new/zsx242030:branch_d...zsx242030:master
To https://gitee.com/zsx242030/sm.git
* [new branch] branch_d -> branch_d
# 合并分支
# master分支操作
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
# 合并
$ git merge origin/branch_d
$ git merge branch_d
Updating 8cb57f6..d735ee3
Fast-forward
a.txt | 3 ++-
b.txt | 0
e.txt | 1 +
3 files changed, 3 insertions(+), 1 deletion(-)
delete mode 100644 b.txt
create mode 100644 e.txt
# 推送
$ git push origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/zsx242030/sm.git
8cb57f6..d735ee3 master -> master
$ git log --pretty=format:"%h: %cd %s" --graph
* d735ee3: Sat May 27 17:22:58 2023 +0800 branch_d | update a.txt | update b.txt | update e.txt
* 8cb57f6: Sat May 27 13:31:13 2023 +0800 branch_c | update a.txt | delete e.txt
* 5b05cb6: Sat May 27 13:17:12 2023 +0800 branch_b | update a.txt | add new.txt
* ddbfc0b: Sat May 27 09:53:59 2023 +0800 branch_a | update a.txt | add new.txt
* 87d5c63: Sat May 27 09:40:12 2023 +0800 add f.txt
* 47e8b59: Sat May 27 09:40:10 2023 +0800 add e.txt
* c0547da: Sat May 27 09:40:10 2023 +0800 add d.txt
* 9c173bb: Sat May 27 09:40:09 2023 +0800 add c.txt
* 8c4a625: Sat May 27 09:40:09 2023 +0800 add b.txt
* 8e58180: Sat May 27 09:40:08 2023 +0800 add a.txt
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。