您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
37 同时变更了文件名和文件内...
发布时间:2020-08-01 15:00:08编辑:雪饮阅读()
首先用pull使得两个端保持一致,然后a端我们变更index.md为index.md2并且push
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git mv index.md index.md2
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git commit -m "mv index.md to index.md2"
[test34 ec37954] mv index.md to index.md2
1 file changed, 0 insertions(+), 0 deletions(-)
rename index.md => index.md2 (100%)
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 236 bytes | 236.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:xueyin220807/moral.git
f72dd87..ec37954 test34 -> test34
接下来我们用b端修改index.md的内容并push
[root@localhost moral2]# vi index.md
[root@localhost moral2]# git add index.md
[root@localhost moral2]# git commit -m "manor 庄园 领地"
[test34 867e1b9] manor 庄园 领地
1 file changed, 1 insertion(+)
[root@localhost moral2]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
To git@github.com:xueyin220807/moral.git
! [rejected] test34 -> test34 (fetch first)
error: failed to push some refs to 'git@github.com:xueyin220807/moral.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 merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我们会发现push失败有冲突了,因为此时对于客户端b来说远端的文件名叫index.md2和自己冲突了自己修改的文件明明是index.md,那么我们尝试用pull是否能够智能帮我们解决这一状况。
[root@localhost moral2]# git pull
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 2 (delta 1), reused 2 (delta 1), pack-reused 0
Unpacking objects: 100% (2/2), done.
From github.com:xueyin220807/moral
f72dd87..ec37954 test34 -> origin/test34
Merge made by the 'recursive' strategy.
index.md => index.md2 | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename index.md => index.md2 (100%)
很显然遇到该种情况pull可以秒解决,帮你自动合并和解决冲突,那么接下来再次push下b端
[root@localhost moral2]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Counting objects: 8, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 618 bytes | 0 bytes/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 2 local objects.
To git@github.com:xueyin220807/moral.git
ec37954..8b45adf test34 -> test34
关键字词:git,文件名,文件内容,不同人,相同文件,冲突,修改