development:system:git
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
development:system:git [2024/08/12 13:44] – [Git Rebase & Git Merge] tungnt | development:system:git [2024/08/15 09:03] (current) – tungnt | ||
---|---|---|---|
Line 51: | Line 51: | ||
Identity added: / | Identity added: / | ||
$ ssh-add -l | $ ssh-add -l | ||
- | 4096 SHA256:HntA0FUgaD0ELTaHSU/ | + | 4096 SHA256:HntA0FUgaD0***EjnP6aXyCvM |
- | 4096 SHA256:2cJDMSnLCJPnd6K4cIdjmI58FwJ/ | + | 4096 SHA256:2cJDMSnLCJP***Wrml4S8ulHw |
</ | </ | ||
Line 62: | Line 62: | ||
| | ||
ssh-add / | ssh-add / | ||
- | ssh-add / | ||
ssh-add / | ssh-add / | ||
Line 350: | Line 349: | ||
{{ : | {{ : | ||
+ | |||
+ | <code bash> | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch | ||
+ | develop | ||
+ | * main | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test1 | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2 | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1 | ||
+ | Switched to branch ' | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % touch t1.md | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test1 d4dd238] T1 | ||
+ | 1 file changed, 0 insertions(+), | ||
+ | | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | d4dd238 (HEAD -> test1) T1 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % touch t2.md | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test1 cfeb1a6] T2 | ||
+ | 1 file changed, 0 insertions(+), | ||
+ | | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % touch t3.md | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test1 a371709] T3 | ||
+ | 1 file changed, 0 insertions(+), | ||
+ | | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | a371709 (HEAD -> test1) T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2 | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | a371709 (HEAD -> test2, test1) T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test2 ab9eacf] T4 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | ab9eacf (HEAD -> test2) T4 | ||
+ | a371709 (test1) T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1 | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % cat t1.md | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test1 54f6b26] T5 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | 54f6b26 (HEAD -> test1) T5 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test1 6e2e921] T6 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | 6e2e921 (HEAD -> test1) T6 | ||
+ | 54f6b26 T5 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test2 | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m ' | ||
+ | [test2 d3eae48] T7 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | d3eae48 (HEAD -> test2) T7 | ||
+ | ab9eacf T4 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch | ||
+ | develop | ||
+ | main | ||
+ | test1 | ||
+ | * test2 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2_bk | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1 | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test1_bk | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch | ||
+ | develop | ||
+ | main | ||
+ | test1 | ||
+ | * test1_bk | ||
+ | test2 | ||
+ | test2_bk | ||
+ | | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1 | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git merge test2 | ||
+ | Auto-merging t1.md | ||
+ | CONFLICT (content): Merge conflict in t1.md | ||
+ | Automatic merge failed; fix conflicts and then commit the result. | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m 'merge for test1 from test2' | ||
+ | [test1 dec26bf] merge for test1 from test2 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | dec26bf (HEAD -> test1) merge for test1 from test2 | ||
+ | d3eae48 (test2_bk, test2) T7 | ||
+ | 6e2e921 (test1_bk) T6 | ||
+ | 54f6b26 T5 | ||
+ | ab9eacf T4 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch | ||
+ | develop | ||
+ | main | ||
+ | * test1 | ||
+ | test1_bk | ||
+ | test2 | ||
+ | test2_bk | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1_bk | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -D test1 | ||
+ | Deleted branch test1 (was dec26bf). | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test1 | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -D test2 | ||
+ | Deleted branch test2 (was d3eae48). | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test2_bk | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2 | ||
+ | Switched to a new branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1 | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch | ||
+ | develop | ||
+ | main | ||
+ | * test1 | ||
+ | test1_bk | ||
+ | test2 | ||
+ | test2_bk | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git rebase test2 | ||
+ | Auto-merging t1.md | ||
+ | CONFLICT (content): Merge conflict in t1.md | ||
+ | error: could not apply 54f6b26... T5 | ||
+ | hint: Resolve all conflicts manually, mark them as resolved with | ||
+ | hint: "git add/rm < | ||
+ | hint: You can instead skip this commit: run "git rebase --skip" | ||
+ | hint: To abort and get back to the state before "git rebase", | ||
+ | Could not apply 54f6b26... T5 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git rebase --continue | ||
+ | [detached HEAD e245d41] T5 - Version 2 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | Successfully rebased and updated refs/ | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | a16f04e (HEAD -> test1) T6 | ||
+ | e245d41 T5 - Version 2 | ||
+ | d3eae48 (test2_bk, test2) T7 | ||
+ | ab9eacf T4 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test2_bk | ||
+ | Switched to branch ' | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git rebase test1_bk | ||
+ | Auto-merging t1.md | ||
+ | CONFLICT (content): Merge conflict in t1.md | ||
+ | error: could not apply ab9eacf... T4 | ||
+ | hint: Resolve all conflicts manually, mark them as resolved with | ||
+ | hint: "git add/rm < | ||
+ | hint: You can instead skip this commit: run "git rebase --skip" | ||
+ | hint: To abort and get back to the state before "git rebase", | ||
+ | Could not apply ab9eacf... T4 | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add . | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git rebase --continue | ||
+ | [detached HEAD eec7eb5] T4 - Version 2 | ||
+ | 1 file changed, 1 insertion(+) | ||
+ | Successfully rebased and updated refs/ | ||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git log --oneline | ||
+ | e4d0fc8 (HEAD -> test2_bk) T7 | ||
+ | eec7eb5 T4 - Version 2 | ||
+ | 6e2e921 (test1_bk) T6 | ||
+ | 54f6b26 T5 | ||
+ | a371709 T3 | ||
+ | cfeb1a6 T2 | ||
+ | d4dd238 T1 | ||
+ | </ | ||
+ | |||
+ | * git merge: khi xem log các commit sẽ được sắp xếp theo thời gian commit, dùng khi dự án ít người cùng làm. | ||
+ | * git rebase: khi xem log các commit sẽ không sắp xếp theo thời gian commit như git merge, mà sẽ ưu tiên commit của cá nhân lên đầu. Nên sử dụng khi dự án có nhiều người cùng làm. | ||
+ | |||
+ | ====== Git Log ====== | ||
+ | |||
+ | https:// | ||
+ | |||
+ | <code bash> | ||
+ | % git log --oneline | ||
+ | |||
+ | % git log -- filename modules/ | ||
+ | % git log -p -- filename modules/ | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 api.9s.vn % git log --pretty=format:" | ||
+ | 56e4d7fe03 - tungnt.blue@gmail.com, | ||
+ | b668bd133d - tungnt.blue@gmail.com, | ||
+ | 54327213ec - tungnt.blue@gmail.com, | ||
+ | 50db75fa85 - tungnt.blue@gmail.com, | ||
+ | ae02e78fb4 - tungnt.blue@gmail.com, | ||
+ | eaae3faa6f - tungnt.blue@gmail.com, | ||
+ | 7656495fc8 - tungnt.blue@gmail.com, | ||
+ | b0ffc56c41 - tungnt.blue@gmail.com, | ||
+ | 1958516401 - tungnt.blue@gmail.com, | ||
+ | 6ecef6fb81 - tungnt.blue@gmail.com, | ||
+ | cd02aafff4 - tungnt.blue@gmail.com, | ||
+ | 2dcbc9cdb7 - tungnt.blue@gmail.com, | ||
+ | 7dae86672a - tungnt.blue@gmail.com, | ||
+ | 7974263273 - tungnt.blue@gmail.com, | ||
+ | |||
+ | tungnt@MacBook-Pro-cua-Nguyen-2 api.9s.vn % git show 54327213ec | ||
+ | commit 54327213ec68b3e8e75194653a60bb95f9f09e5a | ||
+ | Author: tungnt < | ||
+ | Date: Tue Mar 12 16:44:03 2024 +0700 | ||
+ | |||
+ | Test TCB | ||
+ | |||
+ | diff --git a/ | ||
+ | index 9b98620801..1bbac43c4c 100644 | ||
+ | --- a/ | ||
+ | +++ b/ | ||
+ | @@ -47,11 +47,11 @@ class ExampleController extends BaseController | ||
+ | |||
+ | | ||
+ | |||
+ | - $sign1 = $this-> | ||
+ | - $sign2 = $this-> | ||
+ | + $sign1 = $this-> | ||
+ | + $sign2 = $this-> | ||
+ | |||
+ | - $verify1 = $this-> | ||
+ | - $verify2 = $this-> | ||
+ | + $verify1 = $this-> | ||
+ | + $verify2 = $this-> | ||
+ | |||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
====== Một số lỗi có thể gặp ====== | ====== Một số lỗi có thể gặp ====== | ||
development/system/git.1723470283.txt.gz · Last modified: 2024/08/12 13:44 by tungnt