tutorial on rebase
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
# Git rebase
|
||||
|
||||
Иллюстрация работы режима слияния rebase
|
||||
|
||||
git checkout main && git pull
|
||||
|
||||
## Создайте новую ветку
|
||||
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ git checkout -b feature1
|
||||
Switched to a new branch 'feature1'
|
||||
datamove@magisterslinux:~/practice-repo2$ git branch -v
|
||||
* feature1 faf40d3 changed to git4
|
||||
main faf40d3 changed to git4
|
||||
```
|
||||
|
||||
git status
|
||||
|
||||
что-то в ней сделайте
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ echo 'print("new feature1")' > feature1.py
|
||||
datamove@magisterslinux:~/practice-repo2$ git add feature1.py
|
||||
datamove@magisterslinux:~/practice-repo2$ git commit -m "added feature1" feature1.py
|
||||
[feature1 3af75f7] added feature1
|
||||
1 file changed, 1 insertion(+)
|
||||
create mode 100644 feature1.py
|
||||
```
|
||||
|
||||
смотрим лог коммитов
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ git log --oneline
|
||||
3af75f7 (HEAD -> feature1) added feature1
|
||||
faf40d3 (origin/main, origin/HEAD, main) changed to git4
|
||||
```
|
||||
|
||||
## симулируем изменени в главной ветке - обновляем какой-то другой файл
|
||||
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ git checkout main
|
||||
Switched to branch 'main'
|
||||
Your branch is up to date with 'origin/main'.
|
||||
datamove@magisterslinux:~/practice-repo2$ ls -al
|
||||
total 24
|
||||
drwxr-xr-x 3 datamove masters 4096 Oct 19 10:44 .
|
||||
drwxr-x--- 8 datamove masters 4096 Oct 19 10:43 ..
|
||||
drwxr-xr-x 8 datamove masters 4096 Oct 19 10:44 .git
|
||||
-rw-r--r-- 1 datamove masters 1799 Oct 19 10:39 .gitignore
|
||||
-rw-r--r-- 1 datamove masters 16 Oct 19 10:39 README.md
|
||||
-rw-r--r-- 1 datamove masters 21 Oct 19 10:39 hello.py
|
||||
datamove@magisterslinux:~/practice-repo2$ vi hello.py
|
||||
datamove@magisterslinux:~/practice-repo2$ git commit -m "rebase feature test in main" hello.py
|
||||
[main dbc171d] rebase feature test in main
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
```
|
||||
|
||||
проверяем коммит
|
||||
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ git log --oneline
|
||||
dbc171d (HEAD -> main) rebase feature test in main
|
||||
```
|
||||
|
||||
## выполяем ребейз
|
||||
|
||||
```bash
|
||||
datamove@magisterslinux:~/practice-repo2$ git checkout feature1
|
||||
Switched to branch 'feature1'
|
||||
datamove@magisterslinux:~/practice-repo2$ git rebase main
|
||||
Successfully rebased and updated refs/heads/feature1.
|
||||
datamove@magisterslinux:~/practice-repo2$ git log --oneline
|
||||
be92088 (HEAD -> feature1) added feature1
|
||||
dbc171d (main) rebase feature test in main
|
||||
faf40d3 (origin/main, origin/HEAD) changed to git4
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user