git add README test rb LICENSE git commit
Данные репозитория с единственным коммитом $ git add README test. rb LICENSE $ git commit -m 'initial commit of my project' 1
Создание ветви $ git branch testing 3
Указатели на ветви $ git checkout testing 4
Добавление нового коммита $ vim test. rb $ git commit -a -m 'made a change' 5
История с разошедшимися ветками $ vim test. rb $ git commit -a -m 'made other changes' 7
Работа над новой проблемой $ git checkout -b iss 53 Switched to a new branch "iss 53" Или $ git branch iss 53 $ git checkout iss 53 8
Работа над проблемой и ошибкой $ vim index. html $ git commit -a -m 'added a new footer [issue 53]' $ git checkout master Switched to branch "master" $ git checkout -b 'hotfix' Switched to a new branch "hotfix" $ vim index. html $ git commit -a -m 'fixed the broken email address' [hotfix]: created 3 a 0874 c: "fixed the broken email address" 1 files changed, 0 insertions(+), 1 deletions(-) 9
Слияние веток $ git checkout master $ git merge hotfix Updating f 42 c 576. . 3 a 0874 c Fast forward README | 1 – 1 files changed, 0 insertions(+), 1 deletions(-) $ git branch -d hotfix Deleted branch hotfix (3 a 0874 c). 10
Продолжение работы над проблемой $ git checkout iss 53 Switched to branch "iss 53" $ vim index. html $ git commit -a –m 'finished the new footer [issue 53]' [iss 53]: created ad 82 d 7 a: "finished the new footer [issue 53]" 1 files changed, 1 insertions(+), 0 deletions(-) 11
Коммит-слияние $ git checkout master $ git merge iss 53 Merge made by recursive. README | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) 12
Конфликты при слиянии $ git merge iss 53 Auto-merging index. html CONFLICT (content): Merge conflict in index. html Automatic merge failed; fix conflicts and then commit the result. Просмотр файл не пошедших на слияние [master*]$ git status index. html: needs merge # On branch master # Changed but not updated: # (use "git add <file>. . . " to update what will be committed) # (use "git checkout -- <file>. . . " to discard changes in working directory) # # unmerged: index. html # 14
Исправление конфликта <<<<<<< HEAD: index. html <div id="footer"> contact : email. support@github. com </div> ======= <div id="footer"> please contact us at support@github. com </div > >>>>>>> iss 53: index. html <div id="footer"> please contact us at email. support@github. com </div> $ git add index. html $ git commit –m “End merging” 15
- Slides: 15