本文共 5644 字,大约阅读时间需要 18 分钟。
[root@ ~/Git_test_多人协作和冲突合并/branch_test]$ lsREADME.md[root@ ~/Git_test_多人协作和冲突合并/branch_test]$ git branch* master[root@ ~/Git_test_多人协作和冲突合并/branch_test]$ git branch yun[root@ ~/Git_test_多人协作和冲突合并/branch_test]$ git branch* master yun[root@ ~/Git_test_多人协作和冲突合并/branch_test]$
[root@ ~/branch_test]$ lsREADME.md[root@ ~/branch_test]$ git checkout yun切换到分支 'yun'[root@ ~/branch_test]$ git branch master* yun[root@ ~/branch_test]$ lsREADME.md[root@ ~/branch_test]$ touch yun1.c[root@ ~/branch_test]$ lsREADME.md yun1.c[root@ ~/branch_test]$ git add yun1.c[root@ ~/branch_test]$ git commit -m "yun1.c"*** Please tell me who you are.Run git config --global user.email "you@example.com" git config --global user.name "Your Name"to set your account's default identity.Omit --global to set the identity only in this repository.fatal: empty ident name not allowed
[root@ ~/branch_test]$ git commit -m "yun1.c" [yun eb267c4] yun1.c 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 yun1.c
[root@ ~/branch_test]$ git branch * master origin yun[root@ ~/branch_test]$ lsREADME.md yun1.c[root@ ~/branch_test]$ cat yun1.c hello world[root@ ~/branch_test]$ git push origin masterTotal 0 (delta 0), reused 0 (delta 0)To git@git.github.com:kouhaozhe/branch_test.git eb267c4..025a01e master -> master
yun1.c 12 Byteshello world
khz:branch_test kouhz$ lsREADME.md yun1.ckhz:branch_test kouhz$ vim yun1.c khz:branch_test kouhz$ cat yun1.c HELLO WORLDkhz:branch_test kouhz$ git add yun1.c khz:branch_test kouhz$ git commit -m "HELLO WORLD"[master 75da4f2] HELLO WORLD 1 file changed, 1 insertion(+)khz:branch_test kouhz$ git pushTo git.github.com:kouhaozhe/branch_test.git ! [rejected] master -> master (fetch first)error: failed to push some refs to 'git@git.github.com:kouhaozhe/branch_test.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.khz:branch_test kouhz$
<<<<<<< HEADHELLO WORLD=======hello world>>>>>>> 8d4d57c701bfbda71cc442caf2017c01437a80d1
yun 分支添加文字并提交
[root@ ~/branch_test]$ git branch master* yun[root@ ~/branch_test]$ lsREADME.md yun1.c[root@ ~/branch_test]$ vim yun1.c [root@ ~/branch_test]$ cat yun1.c yun hello[root@ ~/branch_test]$ git add yun1.c[root@ ~/branch_test]$ git commit -m "yun yun1.c"[yun 4d7c92c] yun yun1.c 1 file changed, 1 insertion(+), 1 deletion(-)[root@ ~/branch_test]$ git pushCounting objects: 5, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 278 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote: remote: To create a merge request for yun, visit:remote: http://git.github.com/kouhaozhe/branch_test/merge_requests/new?merge_request%5Bsource_branch%5D=yunremote: To git@git.github.com:kouhaozhe/branch_test.git 025a01e..4d7c92c yun -> yun[root@ ~/Git_test_多人协作和冲突合并/branch_test]$
khz:branch_test kouhz$ git branch mac* master
同步之后没有yun这个分支,操作命令
切换另一台主机创建的分支git checkout -b yun origin/yun
Tips:
error: you need to resolve your current index firstkhz:branch_test kouhz$ git reset --merge
khz:branch_test kouhz$ git checkout -b yun origin/yun Branch ‘yun’ set up to track remote branch ‘yun’ from ‘origin’. Switched to a new branch ‘yun’khz:branch_test kouhz$ cat yun1.c <<<<<<< HEADhello worldHELLO WORLD=======yun hello>>>>>>> 4d7c92c5686128aa3c99c25f3dbfdbbd88f8cf5ekhz:branch_test kouhz$ vim yun1.c khz:branch_test kouhz$ cat yun1.c yun hellohello worldHELLO WORLDkhz:branch_test kouhz$ git add yun1.c khz:branch_test kouhz$ git commit -m "mac"[yun ae006aa] mackhz:branch_test kouhz$ git push origin yunCounting objects: 6, done.Delta compression using up to 4 threads.Compressing objects: 100% (4/4), done.Writing objects: 100% (6/6), 577 bytes | 577.00 KiB/s, done.Total 6 (delta 0), reused 0 (delta 0)remote: remote: To create a merge request for yun, visit:remote: http://git.github.com/kouhaozhe/branch_test/merge_requests/new?merge_request%5Bsource_branch%5D=yunremote: To git.github.com:kouhaozhe/branch_test.git 4d7c92c..ae006aa yun -> yun
[root@ ~/branch_test]$ git pullremote: Counting objects: 6, done.remote: Compressing objects: 100% (4/4), done.remote: Total 6 (delta 0), reused 0 (delta 0)Unpacking objects: 100% (6/6), done.来自 git.github.com:kouhaozhe/branch_test 4d7c92c..ae006aa yun -> origin/yunThere is no tracking information for the current branch.Please specify which branch you want to merge with.See git-pull(1) for details git pullIf you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/ yun
[root@ ~/branch_test]$ cat yun1.c yun hello[root@ ~/branch_test]$ git pull更新 4d7c92c..ae006aaFast-forward yun1.c | 2 ++ 1 file changed, 2 insertions(+)[root@ ~/Git_test_多人协作和冲突合并/branch_test]$ cat yun1.c yun hellohello worldHELLO WORLD
git config --global credential.helper store
转载地址:http://saorb.baihongyu.com/