$ git branch testing $ git branch * master testing
$ ls README $ echo 'w3cschool.cc' > test.txt $ git add . $ git commit -m 'add test.txt' [master 048598f] add test.txt 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 hello.php create mode 100644 test.txt $ ls README test.txt $ git checkout testing Switched to branch 'testing' $ ls README hello.php
$ git checkout master Switched to branch 'master' $ ls README test.txt
$ git checkout -b newtest Switched to a new branch 'newtest' $ git rm test2.txt rm 'test2.txt' $ ls README test.txt $ git commit -am 'removed test2.txt' [newtest 556f0a0] removed test2.txt 1 file changed, 1 deletion(-) delete mode 100644 test2.txt $ git checkout master Switched to branch 'master' $ ls README test.txt test2.txt
$ git branch * master testing $ git branch -d testing Deleted branch testing (was 85fc7e7). $ git branch * master
$ git branch * master newtest $ ls README test.txt test2.txt $ git merge newtest Updating 2e082b7..556f0a0 Fast-forward test2.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test2.txt $ ls README test.txt
$ git branch * master $ cat test.txt w3cschool.cc 首先,我们创建一个叫做"change_site"的分支,切换过去,我们将内容改为 www.w3cschool.cc 。 $ git checkout -b change_site Switched to a new branch 'change_site' $ vim test.txt $ head -1 test.txt www.w3cschool.cc $ git commit -am 'changed the site' [change_site d7e7346] changed the site 1 file changed, 1 insertion(+), 1 deletion(-)
$ git checkout master Switched to branch 'master' $ head -1 test.txt w3cschool.cc $ vim test.txt $ cat test.txt w3cschool.cc 新增加一行 $ git diff diff --git a/test.txt b/test.txt index 704cce7..f84c2a4 100644 --- a/test.txt +++ b/test.txt @@ -1 +1,2 @@ w3cschool.cc +新增加一行 $ git commit -am '新增加一行' [master 14b4dca] 新增加一行 1 file changed, 1 insertion(+)
$ git merge change_site Auto-merging test.txt CONFLICT (content): Merge conflict in test.txt Automatic merge failed; fix conflicts and then commit the result. $ cat test.txt <<<<<<< HEAD w3cschool.cc 新增加一行 ======= www.w3cschool.cc >>>>>>> change_site
$ vim test.txt $ cat test.txt www.w3cschool.cc 新增加一行 $ git diff diff --cc test.txt index f84c2a4,bccb7c2..0000000 --- a/test.txt +++ b/test.txt @@@ -1,2 -1,1 +1,2 @@@ - w3cschool.cc + www.w3cschool.cc +新增加一行
$ git status -s UU test.txt $ git add test.txt $ git status -s M test.txt $ git commit [master 88afe0e] Merge branch 'change_site'
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有