Git的使用 checkout push merge
D:\laragon\www\laravel-qa>git branch
* master
D:\laragon\www\laravel-qa>git checkout -b lesson-2
Switched to a new branch ‘lesson-2‘
D:\laragon\www\laravel-qa>git status On branch lesson-2 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: app/User.php Untracked files: (use "git add <file>..." to include in what will be committed) app/Http/Controllers/QuestionController.php app/Models/ database/factories/QuestionFactory.php database/migrations/2020_05_09_192154_create_questions_table.php no changes added to commit (use "git add" and/or "git commit -a") D:\laragon\www\laravel-qa>git add -A warning: LF will be replaced by CRLF in app/User.php. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/Http/Controllers/QuestionController.php. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/Models/Question.php. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in database/factories/QuestionFactory.php. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in database/migrations/2020_05_09_192154_create_questions_table.php. The file will have its original line endings in your working directory D:\laragon\www\laravel-qa>git commit -m "generate question model via artisan model generator" [lesson-2 1851bad] generate question model via artisan model generator 5 files changed, 174 insertions(+) create mode 100644 app/Http/Controllers/QuestionController.php create mode 100644 app/Models/Question.php create mode 100644 database/factories/QuestionFactory.php create mode 100644 database/migrations/2020_05_09_192154_create_questions_table.php D:\laragon\www\laravel-qa>git push -u origin lesson-2 Enumerating objects: 22, done. Counting objects: 100% (22/22), done. Delta compression using up to 6 threads Compressing objects: 100% (13/13), done. Writing objects: 100% (14/14), 2.51 KiB | 367.00 KiB/s, done. Total 14 (delta 4), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (4/4), completed with 4 local objects. remote: remote: Create a pull request for ‘lesson-2‘ on GitHub by visiting: remote: https://github.com/dzkjz/laravel-qa/pull/new/lesson-2 remote: To https://github.com/dzkjz/laravel-qa.git * [new branch] lesson-2 -> lesson-2 Branch ‘lesson-2‘ set up to track remote branch ‘lesson-2‘ from ‘origin‘. D:\laragon\www\laravel-qa>git checkout master Switched to branch ‘master‘ Your branch is up to date with ‘origin/master‘. D:\laragon\www\laravel-qa>git merge lesson-2 Updating ad06dbf..1851bad Fast-forward app/Http/Controllers/QuestionController.php | 85 ++++++++++++++++++++++ app/Models/Question.php | 24 ++++++ app/User.php | 8 ++ database/factories/QuestionFactory.php | 12 +++ .../2020_05_09_192154_create_questions_table.php | 45 ++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 app/Http/Controllers/QuestionController.php create mode 100644 app/Models/Question.php create mode 100644 database/factories/QuestionFactory.php create mode 100644 database/migrations/2020_05_09_192154_create_questions_table.php D:\laragon\www\laravel-qa>git push -u origin master Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 To https://github.com/dzkjz/laravel-qa.git ad06dbf..1851bad master -> master Branch ‘master‘ set up to track remote branch ‘master‘ from ‘origin‘. D:\laragon\www\laravel-qa>
git checkout –b lesson-2
执行后
之后的编辑结果都在该分支
当执行git checkout master切换到主节点后,会发现修改的代码或新增的文件都消失了,但是
执行 git merge lesson-2之后,就会将lesson-2的修改结果融合到主分支,lesson-2修改的代码或新增的文件就又都回来了。
相关推荐
formula 2020-11-12
huhongfei 2020-11-05
乾坤一碼農 2020-10-27
liumengyanysu 2020-10-22
E哥的aws认证攻略 2020-10-15
tianyafengxin 2020-10-08
guying 2020-10-05
好脑筋不如烂笔头 2020-09-17
nebulali 2020-09-11
佛系程序员J 2020-09-15
fenggit 2020-09-15
JustHaveTry 2020-09-11
兄dei努力赚钱吧 2020-09-06
IngeniousIT 2020-08-25
liumengyanysu 2020-08-17
guying 2020-08-16