【Git】08 多人单分支协作场景


文章目录

  • 一、场景1:不同人修改不同文件
    • 1.1 场景描述
    • 1.2 场景复现
      • 1.2.1 克隆到本地
      • 1.2.2 新建分支
      • 1.2.3 B修改、提交与推送
      • 1.2.4 A修改与提交
      • 1.2.5 B再次修改并推送
      • 1.2.6 A推送报错
    • 1.3 解决
  • 二、场景2:不同人修改同文件的不同区域
    • 2.1 场景描述
    • 2.2 场景复现
      • 2.2.1 B修改内容
      • 2.2.2 A修改内容并推送
      • 2.2.3 B推送报错
    • 2.3 解决
  • 三、场景3:不同人修改同文件的同区域
    • 3.1 场景描述
    • 3.2 场景复现
      • 3.2.1 用户A修改提交并推送
      • 3.2.2 用户B修改提交遇报错
    • 3.3 解决
  • 四、场景4:同时变更文件名和内容
    • 4.1 场景描述
    • 4.2 场景复现
      • 4.2.1 用户A修改文件名
    • 4.2.2 用户B修改文件内容
      • 4.2.3 用户Apush到远端
      • 4.2.4 用户Bpush到远端报错
    • 4.3 解决
  • 五、场景5:多人把同一文件改成不同名称
    • 5.1 场景描述
    • 5.2 场景复现
      • 5.2.1 用户A修改名称
      • 5.2.2 用户B修改文件名
      • 5.2.3 用户Apush报错
    • 5.3 解决
  • 六、总结


一、场景1:不同人修改不同文件

1.1 场景描述

假定A、B两用户对Git项目做操作,遇到场景:B在提交了一次commit之后,A将项目clone了下来,并在此基础上进行操作,但B又继续进行操作更新(对不同文件进行修改)并再次提交了commit到服务端。

1.2 场景复现

1.2.1 克隆到本地

用户B将远端库上的项目代码clone到本地,准备在此基础上进行项目代码的修改:

git clone https://gitee.com/asdfv1929/test.git test

git config --add --local user.name tom
git config --add --local user.email tom@163.com

1.2.2 新建分支

在远端库Web端仓库中新建分支,用于测试环境:
在这里插入图片描述

B的本地端更新远程库,将新建的分支纳入到本地:

git remote update
Fetching gitee
From https://gitee.com/asdfv1929/test
 * [new branch]      add_commands -> gitee/add_commands

git branch -av
* master                     73c6ad9 merge readme
  temp                       1395813 add readme
  remotes/gitee/add_commands 73c6ad9 merge readme
  remotes/gitee/master       73c6ad9 merge readme
  remotes/gitee/temp         1395813 add readme

1.2.3 B修改、提交与推送

B进入到新分支中,修改其下的readme文件内容,并最终推送到远端服务器上。

git checkout -b add_commands gitee/add_commands
Switched to a new branch 'add_commands'
branch 'add_commands' set up to track 'gitee/add_commands'.

~/Desktop/test (add_commands)
vi readme

~/Desktop/test (add_commands)
git add -u

~/Desktop/test (add_commands)
git status
On branch add_commands
Your branch is up to date with 'gitee/add_commands'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   readme


~/Desktop/test (add_commands)
git commit -m 'add commands in readme'
[add_commands a82933e] add commands in readme
 1 file changed, 2 insertions(+)

~/Desktop/test (add_commands)
git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 310 bytes | 103.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   73c6ad9..a82933e  add_commands -> add_commands

1.2.4 A修改与提交

用户A看到了B的最新一次提交后,准备在此基础上修改add_commands分支上的文件内容。

git branch -av
* master                      73c6ad9 merge readme
  remotes/origin/HEAD         -> origin/master
  remotes/origin/add_commands a82933e add commands in readme
  remotes/origin/master       73c6ad9 merge readme
  remotes/origin/temp         1395813 add readme

# 切换到分支上,若本地没有则自动创建,并与远程库中的同步分支进行关联
git checkout -b add_commands origin/add_commands
Switched to a new branch 'add_commands'
branch 'add_commands' set up to track 'origin/add_commands'.

用户A在分支中修改了另一个文件file1的内容,并进行了commit。

vi file1

git commit -am 'edit file1'
warning: LF will be replaced by CRLF in file1.
The file will have its original line endings in your working directory
[add_commands 4fc78ae] edit file1
 1 file changed, 1 insertion(+)

注意,此时A并未push到远端库上!

1.2.5 B再次修改并推送

在用户A提交了commit但尚未push到远端服务器时,用户B又一次更新了,并且push到了远端上:

vi readme

~/Desktop/test (add_commands)
git commit -am "second edit of B"
[add_commands 88ea401] second edit of B
 1 file changed, 1 insertion(+)

~/Desktop/test (add_commands)
git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 289 bytes | 289.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   a82933e..88ea401  add_commands -> add_commands

1.2.6 A推送报错

之后,A准备将本地代码push到远端库上时,就会报错,报错原因是远端包含了一些work但本地是没有的,其实就是用户B的最新提交和A本地的内容发生了冲突。

git push
To https://gitee.com/asdfv1929/test.git
 ! [rejected]        add_commands -> add_commands (fetch first)
error: failed to push some refs to 'https://gitee.com/asdfv1929/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

1.3 解决

报错原因是B提交了最新一次内容,但A是在B的上一次提交内容基础上进行修改的,所以此时A只需要将远端分支上最新的内容拉取下来,并将其与本地内容进行合并,最后重新push到远端服务器上即可。

git fetch gitee

git merge gitee/add_commands      # 此时A处在add_commands分支上
Merge made by the 'ort' strategy.
 readme | 1 +
 1 file changed, 1 insertion(+)

git push gitee
Enumerating objects: 9, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 6 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 555 bytes | 555.00 KiB/s, done.
Total 5 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   88ea401..5283e22  add_commands -> add_commands

远端库上,file1文件和readme文件的更新内容同时存在了。
在这里插入图片描述

二、场景2:不同人修改同文件的不同区域

2.1 场景描述

不同人修改了同一文件的不同区域。例如,用户A、B都对readme文件进行了修改,但修改的是文件中的不同区域部分

2.2 场景复现

2.2.1 B修改内容

用户B修改readme文件中间区域内的内容,并进行了commit提交。

vi readme

asdfv@DESKTOP-JWJ MINGW64 ~/Desktop/test (add_commands)
$ git commit -am 'userB edit'
[add_commands 0a9d613] userB edit
 1 file changed, 1 insertion(+), 1 deletion(-)

注意,此时B是未push到远端的状态!

2.2.2 A修改内容并推送

用户A也在修改readme文件的内容,但是在另一个区域部分,例如文件末尾;
commit完成后便push到服务端。

vi readme

/g/test (add_commands)
git commit -am 'userA edit'
[add_commands 7fcd9b5] userA edit
 1 file changed, 2 insertions(+)

/g/test (add_commands)
git push gitee
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 298 bytes | 298.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   5283e22..7fcd9b5  add_commands -> add_commands

2.2.3 B推送报错

此时,用户B将其本地的commit去push推送到远端时,就会发生报错。

git push
To https://gitee.com/asdfv1929/test.git
 ! [rejected]        add_commands -> add_commands (fetch first)
error: failed to push some refs to 'https://gitee.com/asdfv1929/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

2.3 解决

用户B只需再次将远端库代码拉取到本地,并进行合并,最后重新push到远端即可。

git fetch gitee
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 278 bytes | 8.00 KiB/s, done.
From https://gitee.com/asdfv1929/test
   5283e22..7fcd9b5  add_commands -> gitee/add_commands

~/Desktop/test (add_commands)
git merge
Auto-merging readme
Merge made by the 'ort' strategy.
 readme | 2 ++
 1 file changed, 2 insertions(+)

git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 6 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 603 bytes | 603.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   7fcd9b5..2260cf2  add_commands -> add_commands

可以看到,用户A、B两人对同一文件readme的不同区域上的编辑内容都呈现出来了。
在这里插入图片描述

三、场景3:不同人修改同文件的同区域

3.1 场景描述

多个用户修改相同文件的相同区域。
例如,用户A和B都基于相同commit在做修改更新操作,且是对同一文件的相同区域做操作。

3.2 场景复现

3.2.1 用户A修改提交并推送

用户A修改readme文件后,进行commit之后便立即push了(先B一步推送)。

vi readme

~/Desktop/test (add_commands)
git status
On branch add_commands
Your branch is up to date with 'gitee/add_commands'.

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

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

git commit -am 'userA edit readme'
[add_commands dd37a4d] userA edit same file same region
 1 file changed, 2 insertions(+)

git push gitee
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 304 bytes | 304.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   2260cf2..dd37a4d  add_commands -> add_commands

3.2.2 用户B修改提交遇报错

用户B此时也在修改readme文件,且修改的区域与用户A相同,都是在文件的末尾。

vi readme

/g/test (add_commands)
git commit -am"userB edit readme"
[add_commands 6b86e17] userB edit readme
 1 file changed, 1 insertion(+)

但此时用户B去push时,就会报错。

/g/test (add_commands)
git push gitee
To https://gitee.com/asdfv1929/test.git
 ! [rejected]        add_commands -> add_commands (fetch first)
error: failed to push some refs to 'https://gitee.com/asdfv1929/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

3.3 解决

遇到报错,那么用户B就需要先将远端库最新版本拉取下来,这边使用pull命令,但遇到告警:Automatic merge failed。这是Git在自动进行合并时发生冲突了,因为两用户都在同一文件的相同区域进行了编辑,Git就无法判断出做什么操作:是都保留、只保留A内容或者只保留B内容。这就需要用户来进行干预选择。

/g/test (add_commands)
git pull gitee
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 268 bytes | 11.00 KiB/s, done.
From https://gitee.com/asdfv1929/test
   a5658ce..4994050  add_commands -> gitee/add_commands
Auto-merging readme
CONFLICT (content): Merge conflict in readme
Automatic merge failed; fix conflicts and then commit the result.

此时去查看readme文件的内容:

/g/test (add_commands|MERGING)
cat readme
this is a test of push

second edit
hahhahahahaha
hahahahahah
userB edit readme between haha-content
content of add_commands branch
 second edit of user B

userA edit readme in the end.

<<<<<<< HEAD
userB edit readme!!!
=======
userA edit readme!!!
>>>>>>> 4994050c587d0f11b63c5e06d2dcc7a481e6c88b

其中,<<<<<<< HEAD与"=======" 之间的内容表示为自己(用户B)的编辑内容,"======="和>>>>>>> 4994050c587d0f11b63c5e06d2dcc7a481e6c88b之间的内容为另一用户(用户A)的内容。

这边选择都保留,只需要把上面readme文件中的三处特殊标记删除并保存,最后提交commit和push即可。

vi readme
...
userB edit readme!!!
userA edit readme!!!

/g/test (add_commands|MERGING)
git status
On branch add_commands
Your branch and 'gitee/add_commands' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   readme

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

/g/test (add_commands|MERGING)
git commit -am'resolve 2 users content'
[add_commands b6a3675] resolve 2 users content

/g/test (add_commands)
git push
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 6 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 548 bytes | 548.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   4994050..b6a3675  add_commands -> add_commands

在这里插入图片描述

四、场景4:同时变更文件名和内容

4.1 场景描述

多人同时变更了文件名称及其内容。

4.2 场景复现

4.2.1 用户A修改文件名

用户A对文件file1进行了重命名,并进行了commit,但尚未push。

git mv file1 file.txt

~/Desktop/test (add_commands)
git status
On branch add_commands
Your branch is up to date with 'gitee/add_commands'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        renamed:    file1 -> file.txt


~/Desktop/test (add_commands)
git commit -am'mv file1 file.txt'
[add_commands 1f27e65] mv file1 file.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename file1 => file.txt (100%)

4.2.2 用户B修改文件内容

用户B修改了同一文件file1的内容,且进行了commit。

/g/test (add_commands)
$ vi file1

/g/test (add_commands)
git commit -am'userB add content in file1'
[add_commands 850703b] userB add content in file1
 1 file changed, 2 insertions(+)

4.2.3 用户Apush到远端

用户A先一步进行了push,此时远端库发生了更新。

~/Desktop/test (add_commands)
git push gitee
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 279 bytes | 279.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   b6a3675..1f27e65  add_commands -> add_commands

4.2.4 用户Bpush到远端报错

后面,用户B再去push时就会报错。

/g/test (add_commands)
git push gitee
To https://gitee.com/asdfv1929/test.git
 ! [rejected]        add_commands -> add_commands (fetch first)
error: failed to push some refs to 'https://gitee.com/asdfv1929/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

4.3 解决

此时就需要用户B重新将远端库上最新版本库pull拉取到本地,Git会自动将两处变动进行合并(A的重命名和B的添加内容),最后重新push即可。

/g/test (add_commands)
git pull gitee
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 259 bytes | 18.00 KiB/s, done.
From https://gitee.com/asdfv1929/test
   b6a3675..1f27e65  add_commands -> gitee/add_commands
Merge made by the 'ort' strategy.
 file1 => file.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename file1 => file.txt (100%)

/g/test (add_commands)
ls
file.txt  file2  readme

/g/test (add_commands)
cat file.txt
user A edit file1

userB edit file1!!!

/g/test (add_commands)
git push
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 6 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 651 bytes | 651.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   1f27e65..06e4177  add_commands -> add_commands

五、场景5:多人把同一文件改成不同名称

5.1 场景描述

多个人把同一文件修改成不同的文件名称。

5.2 场景复现

5.2.1 用户A修改名称

用户A对file.txt文件进行了重命名,并提交了commit,但尚未push

~/Desktop/test/test (add_commands)
ls
file.txt  file2.txt  fileB.html  readme

~/Desktop/test/test (add_commands)
git mv file.txt fileA.txt

~/Desktop/test/test (add_commands)
git commit -am'userA mv file.txt fileA.txt'
[add_commands 3913944] userA mv file.txt fileA.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename file.txt => fileA.txt (100%)

5.2.2 用户B修改文件名

用户B对同一文件file.txt也修改了文件名,且命名不同,并最后push到了远端库上。

/g/test/test (add_commands)
git mv file.txt fileB.txt

/g/test/test (add_commands)
git commit -am'userB mv file.txt fileB.txt'
[add_commands bda28ab] userB mv file.txt fileB.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename file.txt => fileB.txt (100%)

/g/test/test (add_commands)
git push origin
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 233 bytes | 233.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   7801623..bda28ab  add_commands -> add_commands

5.2.3 用户Apush报错

此时用户A也去push时就会报错。

~/Desktop/test/test (add_commands)
git push origin
To https://gitee.com/asdfv1929/test.git
 ! [rejected]        add_commands -> add_commands (fetch first)
error: failed to push some refs to 'https://gitee.com/asdfv1929/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

5.3 解决

用户Apush遇到报错,这是因为本地库与远端库发生了冲突。
那正常情况下,都是先将远端库拉取到本地,并与本地内容进行合并,但此处会遇到冲突告警。

git pull origin
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (2/2), 213 bytes | 26.00 KiB/s, done.
From https://gitee.com/asdfv1929/test
   7801623..bda28ab  add_commands -> origin/add_commands
CONFLICT (rename/rename): file.txt renamed to fileA.txt in HEAD and to fileB.txt in bda28ab39ac039e39d1243290ee35bd8624a5e64.
Automatic merge failed; fix conflicts and then commit the result.

Automatic merge failed自动合并失败,这是因为Git无法判断该保留哪种重命名。
此时用户A和B需达成一致,并最终选择其一(人工干预)。

用户A这边查看一下git的状态,并选择最后的决定(选择哪个名字)。

~/Desktop/test/test (add_commands|MERGING)
git status
On branch add_commands
Your branch and 'origin/add_commands' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
        both deleted:    file.txt
        added by us:     fileA.txt
        added by them:   fileB.txt

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

~/Desktop/test/test (add_commands|MERGING)   # 留意MERGING,表示处于合并中
git rm file.txt
rm 'file.txt'

~/Desktop/test/test (add_commands|MERGING)
git add fileA.txt                           # 选择保留fileA.txt文件名,另外两种都删除

~/Desktop/test/test (add_commands|MERGING)
git rm fileB.txt
rm 'fileB.txt'

~/Desktop/test/test (add_commands|MERGING)
git status
On branch add_commands
Your branch and 'origin/add_commands' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

~/Desktop/test/test (add_commands|MERGING)
git commit -am'finally choose fileA.txt'         # 提交commit,并最终push到远端
[add_commands de4c6e5] finally choose fileA.txt

~/Desktop/test/test (add_commands)
git push origin
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 6 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 364 bytes | 364.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/asdfv1929/test.git
   bda28ab..de4c6e5  add_commands -> add_commands

用户B这边重新拉取,更新下文件名。

/g/test/test (add_commands)
git pull
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 344 bytes | 43.00 KiB/s, done.
From https://gitee.com/asdfv1929/test
   bda28ab..de4c6e5  add_commands -> origin/add_commands
Updating bda28ab..de4c6e5
Fast-forward
 fileB.txt => fileA.txt | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename fileB.txt => fileA.txt (100%)

/g/test/test (add_commands)
ls
file2.txt  fileA.txt  fileB.html  readme

六、总结

本文主要讲多人在单个分支上操作时常遇到的一些情形。在进行git操作时,对遇到的问题要多熟悉,能做到问题的快速定位,以及后续的及时解决。


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/378053.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

iOS 需求 多语言(国际化)App开发 源码

一直觉得自己写的不是技术&#xff0c;而是情怀&#xff0c;一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的&#xff0c;希望我的这条路能让你们少走弯路&#xff0c;希望我能帮你们抹去知识的蒙尘&#xff0c;希望我能帮你们理清知识的脉络&#xff0…

HGAME 2024 WEEK 1

PWN EzSignIn nc 登录上去即可获得flag hgame{I_HATE_PWN} Web ezHTTP 第一关用Referer&#xff0c;参考&#xff1a;HTTP请求头中Referer的作用_请求转发 请求头里面会有有referer嘛-CSDN博客 HTTP请求中&#xff0c;Referer是header的一部分&#xff0c;当浏览器向web服务…

C++ 内存管理(newdelete)

目录 本节目标 1. C/C内存分布 2. C语言中动态内存管理方式&#xff1a;malloc/calloc/realloc/free 3. C内存管理方式 3.1 new/delete操作内置类型 3.2 new和delete操作自定义类型 4. operator new与operator delete函数 5. new和delete的实现原理 6. 定位new表达式(placem…

HCIA-HarmonyOS设备开发认证V2.0-3.2.轻量系统内核基础-任务管理

目录 一、任务管理1.1、任务状态1.2、任务基本概念1.3、任务管理使用说明1.4、任务开发流程1.5、任务管理接口 一、任务管理 从系统角度看&#xff0c;任务是竞争系统资源的最小运行单元。任务可以使用或等待CPU、使用内存空间等系统资源&#xff0c;并独立于其它任务运行。 O…

【Git版本控制 02】分支管理

目录 一、创建分支 二、切换分支 三、合并分支 四、删除分支 五、合并冲突 六、分支策略 七、bug分支 一、创建分支 # 当前仓库只有 master 一个主分支 # 可通过 git branch 是进行分支管理的命令&#xff0c;可通过不同参数对分支进行查看、创建、删除(base) [rootloc…

上市公司人工智能转型指数及55个工具变量汇总数据集(2024.2月更新)

一、“智能化转型”发文趋势和主题分布 二、数据来源 上市公司年报、官网&#xff0c;中国知网及各期刊官网等三、时间跨度 工具变量&#xff1a;2022-2024年&#xff1b; 上市公司人工智能转型指数&#xff1a;2007-2021年四、数据范围 中国A股上市公司五、数据展示 序号…

基于BatchNorm的模型剪枝【详解+代码】

文章目录 1、BatchNorm&#xff08;BN&#xff09;2、L1与L2正则化2.1 L1与L2的导数及其应用2.2 论文核心点 3、模型剪枝的流程 ICCV经典论文&#xff0c;通俗易懂&#xff01;论文题目&#xff1a;Learning Efficient Convolutional Networks through Network Slimming卷积后能…

Javaweb之SpringBootWeb案例之登录校验功能的详细解析

2. 登录校验 2.1 问题分析 我们已经完成了基础登录功能的开发与测试&#xff0c;在我们登录成功后就可以进入到后台管理系统中进行数据的操作。 但是当我们在浏览器中新的页面上输入地址&#xff1a;http://localhost:9528/#/system/dept&#xff0c;发现没有登录仍然可以进…

用通俗易懂的方式讲解大模型:一个强大的 LLM 微调工具 LLaMA Factory

LLM&#xff08;大语言模型&#xff09;微调一直都是老大难问题&#xff0c;不仅因为微调需要大量的计算资源&#xff0c;而且微调的方法也很多&#xff0c;要去尝试每种方法的效果&#xff0c;需要安装大量的第三方库和依赖&#xff0c;甚至要接入一些框架&#xff0c;可能在还…

Redis篇之持久化

一、为什么要进行持久化 Redis是一个基于内存的键值存储系统&#xff0c;但为了保证数据在服务器重启、故障等情况下不丢失。 二、应该怎么持久化 1.RDB持久化 &#xff08;1&#xff09;RDB是什么 RDB全称Redis Database Backup file&#xff08;Redis数据备份文件&#xff…

RTE2023第九届实时互联网大会:揭秘未来互联网趋势,PPT分享引领行业新思考

随着互联网的不断发展&#xff0c;实时互动技术正逐渐成为新时代的核心驱动力。 在这样的背景下&#xff0c;RTE2023第九届实时互联网大会如期而至&#xff0c;为业界人士提供了一个探讨实时互联网技术、交流创新理念的绝佳平台。 本文将从大会内容、PPT分享价值等方面&#…

ChatGPT高效提问—prompt常见用法

ChatGPT高效提问—prompt常见用法 1.1 角色扮演 ​ prompt最为常见的用法是ChatGPT进行角色扮演。通常我们在和ChatGPT对话时&#xff0c;最常用的方式是一问一答&#xff0c;把ChatGPT当作一个单纯的“陪聊者”。而当我们通过prompt为ChatGPT赋予角色属性后&#xff0c;即使…

Go 语言 for 的用法

For statements 本文简单翻译了 Go 语言中 for 的三种用法&#xff0c;可快速学习 Go 语言 for 的使用方法&#xff0c;希望本文能为你解开一些关于 for 的疑惑。详细内容可见文档 For statements。 For statements with single condition 在最简单的形式中&#xff0c;只要…

DFS——剪枝

dfs在每个点&#xff08;状态&#xff09;的情况比较多&#xff0c;但是节点比较少的时候很常用&#xff0c;我们将每个状态的情况延伸出去&#xff0c;可以画出一棵搜索树。dfs会搜到每一种情况&#xff0c;所以我们实际上可以按照任意顺序来判否。为了优化搜索我们可以在搜索…

Leetcode刷题笔记题解(C++):64. 最小路径和

思路一&#xff1a;dfs深度优先搜索&#xff0c;然后取最小路径值&#xff0c;但是时间消耗较大&#xff0c;时间复杂度可能不满足&#xff0c;代码如下&#xff1a; class Solution { public:int res 1000000;int rows,cols;int minPathSum(vector<vector<int>>…

C#中的浅度和深度复制(C#如何复制一个对象)

文章目录 浅度和深度复制浅度复制深度复制如何选择 浅度和深度复制 在C#中&#xff0c;浅度复制&#xff08;Shallow Copy&#xff09;和深度复制&#xff08;Deep Copy&#xff09;是两种不同的对象复制方式&#xff0c;满足不同的应用场景需求&#xff0c;它们主要区别在于处…

Vivado Tri-MAC IP的例化配置(三速以太网IP)

目录 1 Tri-MAC IP使用RGMII接口的例化配置1.1 Data Rate1.2 interface配置1.3 Shared Logic配置1.4 Features 2 配置完成IP例化视图 1 Tri-MAC IP使用RGMII接口的例化配置 在网络设计中&#xff0c;使用的IP核一般为三速以太网IP核&#xff0c;使用时在大多数场景下为配置为三…

IS-IS 接口认证密码平滑更换

拓扑图 配置 AR1、AR2建立ISIS level-2邻居关系&#xff0c;并配置接口认证密码为huawei sysname AR1 # isis 1is-level level-2network-entity 49.0000.0000.0000.0001.00 # interface GigabitEthernet0/0/0ip address 12.1.1.1 255.255.255.0 isis enable 1isis authentica…

一文学会Axios的使用

异步请求 同步发送请求过程如下 浏览器页面在发送请求给服务器&#xff0c;在服务器处理请求的过程中&#xff0c;浏览器页面不能做其他的操作。只能等到服务器响应结束后才能&#xff0c;浏览器页面才能继续做其他的操作。 异步发送请求过程如下浏览器页面发送请求给服务器&…

百卓Smart管理平台 uploadfile.php 文件上传漏洞【CVE-2024-0939】

百卓Smart管理平台 uploadfile.php 文件上传漏洞【CVE-2024-0939】 一、 产品简介二、 漏洞概述三、 影响范围四、 复现环境五、 漏洞复现手动复现小龙验证Goby验证 免责声明&#xff1a;请勿利用文章内的相关技术从事非法测试&#xff0c;由于传播、利用此文所提供的信息或者工…
最新文章