TungNT (Blue)

tungnt.blue@gmail.com

User Tools

Site Tools


development:system:git

Git

Cài đặt và cấu hình

$ apt-get install git
$ git config --global user.name "TungNT"
$ git config --global user.email "tungnt.blue@gmail.com"

Tạo SSH Key

$ ssh-keygen -t rsa -b 4096 -C "tungnt.blue@gmail.com"

Tạo nhiều tài khoản ssh key

$ ssh-keygen -t rsa -b 4096 -C “tungnt.blue@gmail.com”
Generating public/private rsa key pair.
Enter file in which to save the key (/var/root/.ssh/id_rsa): id_rsa_tungntblue
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa_tungntblue.
Your public key has been saved in id_rsa_tungntblue.pub.
$ ssh-keygen -t rsa -b 4096 -C “nguyentung@mobgame.vn”
Generating public/private rsa key pair.
Enter file in which to save the key (/var/root/.ssh/id_rsa): id_rsa_nguyentung
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa_nguyentung.
Your public key has been saved in id_rsa_nguyentung.pub.
The key fingerprint is:
$ ls -la /var/root/.ssh/
-rw-------   1 root  wheel  3243 Nov  1 10:26 id_rsa
-rw-r--r--   1 root  wheel   747 Nov  1 10:26 id_rsa.pub
-rw-------   1 root  wheel  3243 Nov  1 22:24 id_rsa_nguyentung
-rw-r--r--   1 root  wheel   753 Nov  1 22:24 id_rsa_nguyentung.pub
-rw-------   1 root  wheel  3243 Nov  1 22:21 id_rsa_tungntblue
-rw-r--r--   1 root  wheel   753 Nov  1 22:21 id_rsa_tungntblue.pub
-rw-r--r--   1 root  wheel  5036 Nov  1 10:23 known_hosts

Add các key:

$ ssh-add ~/.ssh/id_rsa_tungntblue
Identity added: /var/root/.ssh/id_rsa_tungntblue (/var/root/.ssh/id_rsa_tungntblue)
$ ssh-add ~/.ssh/id_rsa_nguyentung
Identity added: /var/root/.ssh/id_rsa_nguyentung (/var/root/.ssh/id_rsa_nguyentung)
$ ssh-add -l
4096 SHA256:HntA0FUgaD0***EjnP6aXyCvM /var/root/.ssh/id_rsa_tungntblue (RSA)
4096 SHA256:2cJDMSnLCJP***Wrml4S8ulHw /var/root/.ssh/id_rsa_nguyentung (RSA)

Tạo command add key:

$ vim gi.sh
#! /bin/bash
  
ssh-add /var/root/.ssh/id_rsa_tungntblue
ssh-add /var/root/.ssh/id_rsa_nguyentung

ssh-add -l

$ chmod +x gi.sh
$ ln -s gi.sh /usr/local/bin/gi
$ gi

Cấu hình Host sử dụng key:

$ vim ~/.ssh/config
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_tungntblue

Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_tungntblue

Host git.mobgame.mobi
HostName mobgame.mobi
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_nguyentung

Khởi tạo Git

$ git init
$ git add .
$ git commit -am 'Init source'
$ git remote add origin git@github.com:abc/xyz.git
$ git remote -v
$ git push origin master

Branch

$ git checkout -b dev
$ git checkout -b dev master

$ git branch -D dev

$ git checkout [branch_name] -- [file_path]

$ git diff [branch_1] [branch_2]
$ git diff --name-only [branch_1] [branch_2]
$ git diff [branch_1] [branch_2] --file
$ git diff --name-only master release/complete > diff_master_with_release_complete.txt

Xem log

$ git reflog
$ git reflog master

Sửa commit message cuối cùng

$ git commit --amend

$ git reset --hard [commit_version]

Submodule

git submodule add {GIT_URL} {DIR_PATH}

https://www.atlassian.com/git/tutorials/git-submodule

GitFlow

https://github.com/1sitevn/gitflow

https://nvie.com/posts/a-successful-git-branching-model

tungnt@MacBook-Pro-cua-Nguyen-2 1site % mkdir gitflow
tungnt@MacBook-Pro-cua-Nguyen-2 1site % cd gitflow 
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % ls -la
total 0
drwxr-xr-x  2 tungnt  staff   64 Aug 12 16:14 .
drwxr-xr-x@ 7 tungnt  staff  224 Aug 12 16:14 ..
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo "# gitflow" >> README.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git init
Initialized empty Git repository in /private/var/www/1site/gitflow/.git/
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add README.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m "first commit"
[master (root-commit) 0f7d8f6] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -M main
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git remote add origin git@github.com:1sitevn/gitflow.git
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push -u origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 290 bytes | 290.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:1sitevn/gitflow.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch develop
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch
  develop
* main
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout develop
Switched to branch 'develop'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout main   
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push -u origin develop
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'develop' on GitHub by visiting:
remote:      https://github.com/1sitevn/gitflow/pull/new/develop
remote: 
To github.com:1sitevn/gitflow.git
 * [new branch]      develop -> develop
branch 'develop' set up to track 'origin/develop'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b feature/1-add-test-file develop
Switched to a new branch 'feature/1-add-test-file'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git status
On branch feature/1-add-test-file
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	test.js
 
nothing added to commit but untracked files present (use "git add" to track)
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m '#1 - add a new test.js file'
[feature/1-add-test-file c637c90] #1 - add a new test.js file
 1 file changed, 1 insertion(+)
 create mode 100644 test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push
fatal: The current branch feature/1-add-test-file has no upstream branch.
To push the current branch and set the remote as upstream, use
 
    git push --set-upstream origin feature/1-add-test-file
 
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
 
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push --set-upstream origin feature/1-add-test-file
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 399 bytes | 399.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'feature/1-add-test-file' on GitHub by visiting:
remote:      https://github.com/1sitevn/gitflow/pull/new/feature/1-add-test-file
remote: 
To github.com:1sitevn/gitflow.git
 * [new branch]      feature/1-add-test-file -> feature/1-add-test-file
branch 'feature/1-add-test-file' set up to track 'origin/feature/1-add-test-file'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout develop
Switched to branch 'develop'
Your branch is up to date with 'origin/develop'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git pull
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 906 bytes | 906.00 KiB/s, done.
From github.com:1sitevn/gitflow
   0f7d8f6..e94388a  develop    -> origin/develop
Updating 0f7d8f6..e94388a
Fast-forward
 test.js | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout release-1.0.0 develop
error: pathspec 'release-1.0.0' did not match any file(s) known to git
error: pathspec 'develop' did not match any file(s) known to git
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b release-1.0.0 develop
Switched to a new branch 'release-1.0.0'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git tag 'v1.0.0'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push --tags
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:1sitevn/gitflow.git
 * [new tag]         v1.0.0 -> v1.0.0
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git merge develop
Already up to date.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch
  develop
  feature/1-add-test-file
  main
* release-1.0.0
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push origin release-1.0.0
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'release-1.0.0' on GitHub by visiting:
remote:      https://github.com/1sitevn/gitflow/pull/new/release-1.0.0
remote: 
To github.com:1sitevn/gitflow.git
 * [new branch]      release-1.0.0 -> release-1.0.0
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % ls -la
total 8
drwxr-xr-x   4 tungnt  staff  128 Aug 12 16:43 .
drwxr-xr-x@  7 tungnt  staff  224 Aug 12 16:14 ..
drwxr-xr-x  14 tungnt  staff  448 Aug 12 16:43 .git
-rw-r--r--   1 tungnt  staff   10 Aug 12 16:15 README.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git pull origin main  
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 890 bytes | 445.00 KiB/s, done.
From github.com:1sitevn/gitflow
 * branch            main       -> FETCH_HEAD
   0f7d8f6..9cd0401  main       -> origin/main
Updating 0f7d8f6..9cd0401
Fast-forward
 test.js | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % ls -la
total 16
drwxr-xr-x   5 tungnt  staff  160 Aug 12 16:44 .
drwxr-xr-x@  7 tungnt  staff  224 Aug 12 16:14 ..
drwxr-xr-x  14 tungnt  staff  448 Aug 12 16:44 .git
-rw-r--r--   1 tungnt  staff   10 Aug 12 16:15 README.md
-rw-r--r--   1 tungnt  staff   20 Aug 12 16:44 test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git tag 'v1.0.0'
fatal: tag 'v1.0.0' already exists
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push --tags
Everything up-to-date
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch
  develop
  feature/1-add-test-file
* main
  release-1.0.0
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -d release-1.0.0
Deleted branch release-1.0.0 (was e94388a).
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push origin -d release-1.0.0
To github.com:1sitevn/gitflow.git
 - [deleted]         release-1.0.0
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -d feature/1-add-test-file
Deleted branch feature/1-add-test-file (was c637c90).
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push origin -d feature/1-add-test-file
To github.com:1sitevn/gitflow.git
 - [deleted]         feature/1-add-test-file
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b hotfixs main
Switched to a new branch 'hotfixs'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add test.js
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m '#1 - Hotfix test'
[hotfixs c16aab1] #1 - Hotfix test
 1 file changed, 1 insertion(+), 1 deletion(-)
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push origin hotfixs
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 395 bytes | 395.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'hotfixs' on GitHub by visiting:
remote:      https://github.com/1sitevn/gitflow/pull/new/hotfixs
remote: 
To github.com:1sitevn/gitflow.git
 * [new branch]      hotfixs -> hotfixs
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git branch -D hotfixs
Deleted branch hotfixs (was c16aab1).
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git push origin -d hotfixs
To github.com:1sitevn/gitflow.git
 - [deleted]         hotfixs

Git Rebase & Git Merge

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 'test1'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2
Switched to a new branch 'test2'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1
Switched to branch 'test1'
 
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 'T1'
[test1 d4dd238] T1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 t1.md
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 'T2'
[test1 cfeb1a6] T2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 t2.md
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 'T3'
[test1 a371709] T3
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 t3.md
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 'test2'
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 'Update T1' >> t1.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add .                
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m 'T4'       
[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 'test1'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % cat t1.md 
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo 'Update T5' >> t1.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add .                
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m 'T5'       
[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 'Update T6' >> t2.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add .                
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m 'T6'       
[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 'test2'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % echo 'Update T7' >> t3.md
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git add .                
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git commit -m 'T7'       
[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 'test2_bk'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1
Switched to branch 'test1'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test1_bk
Switched to a new branch 'test1_bk'
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 'test1'
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 'test1_bk'
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 'test1'
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 'test2_bk'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout -b test2
Switched to a new branch 'test2'
tungnt@MacBook-Pro-cua-Nguyen-2 gitflow % git checkout test1
Switched to branch 'test1'
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 <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
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/heads/test1.
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 'test2_bk'
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 <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
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/heads/test2_bk.
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://git-scm.com/book/id/v2/Git-Basics-Viewing-the-Commit-History

% git log --oneline 
 
% git log -- filename modules/core/app/Http/Controllers/ExampleController.php
% git log -p -- filename modules/core/app/Http/Controllers/ExampleController.php
 
tungnt@MacBook-Pro-cua-Nguyen-2 api.9s.vn % git log --pretty=format:"%h - %ae, %ar : %s : %cn" --since="2024-01-01"  --no-merges --author=tungnt -- filename modules/core/app/Http/Controllers/ExampleController.php
56e4d7fe03 - tungnt.blue@gmail.com, 3 months ago : Payout hold with MC : tungnt
b668bd133d - tungnt.blue@gmail.com, 5 months ago : Test TCB VA Key : tungnt
54327213ec - tungnt.blue@gmail.com, 5 months ago : Test TCB : tungnt
50db75fa85 - tungnt.blue@gmail.com, 5 months ago : Test TCB : tungnt
ae02e78fb4 - tungnt.blue@gmail.com, 5 months ago : Test TCB : tungnt
eaae3faa6f - tungnt.blue@gmail.com, 5 months ago : Test TCB : tungnt
7656495fc8 - tungnt.blue@gmail.com, 5 months ago : Update Payout config : tungnt
b0ffc56c41 - tungnt.blue@gmail.com, 6 months ago : Test key : tungnt
1958516401 - tungnt.blue@gmail.com, 6 months ago : Update SMS BIDV 8600664888 : tungnt
6ecef6fb81 - tungnt.blue@gmail.com, 6 months ago : D : tungnt
cd02aafff4 - tungnt.blue@gmail.com, 7 months ago : Debug : tungnt
2dcbc9cdb7 - tungnt.blue@gmail.com, 7 months ago : Golive jira_5001 : tungnt
7dae86672a - tungnt.blue@gmail.com, 7 months ago : MSB VA : tungnt
7974263273 - tungnt.blue@gmail.com, 7 months ago : Update name TiktokLive to Tiktok : tungnt
 
tungnt@MacBook-Pro-cua-Nguyen-2 api.9s.vn % git show 54327213ec
commit 54327213ec68b3e8e75194653a60bb95f9f09e5a
Author: tungnt <tungnt.blue@gmail.com>
Date:   Tue Mar 12 16:44:03 2024 +0700
 
    Test TCB
 
diff --git a/modules/core/app/Http/Controllers/ExampleController.php b/modules/core/app/Http/Controllers/ExampleController.php
index 9b98620801..1bbac43c4c 100644
--- a/modules/core/app/Http/Controllers/ExampleController.php
+++ b/modules/core/app/Http/Controllers/ExampleController.php
@@ -47,11 +47,11 @@ class ExampleController extends BaseController
 
             $aesPlaintTextHash = hash('sha256', $aesPlaintText, true);
 
-            $sign1 = $this->sign($aesPlaintTextHash, storage_path('credentials/rsa/transfer/techcombank/2024/tcb2024/1pay_cks_1.jks'), '***');
-            $sign2 = $this->sign($aesPlaintTextHash, storage_path('credentials/rsa/transfer/techcombank/2024/tcb2024/1pay_cks_2.jks'), '***');
+            $sign1 = $this->sign($aesPlaintTextHash, storage_path('credentials/rsa/transfer/techcombank/2024/1pay_cks_1.jks'), '***');
+            $sign2 = $this->sign($aesPlaintTextHash, storage_path('credentials/rsa/transfer/techcombank/2024/1pay_cks_2.jks'), '***');
 
-            $verify1 = $this->verify($aesPlaintTextHash, $sign1, storage_path('credentials/rsa/transfer/techcombank/2024/tcb2024/1pay_tcb_verify_sign_1.cer'));
-            $verify2 = $this->verify($aesPlaintTextHash, $sign2, storage_path('credentials/rsa/transfer/techcombank/2024/tcb2024/1pay_tcb_verify_sign_2.cer'));
+            $verify1 = $this->verify($aesPlaintTextHash, $sign1, storage_path('credentials/rsa/transfer/techcombank/2024/1pay_tcb_verify_sign_1.cer'));
+            $verify2 = $this->verify($aesPlaintTextHash, $sign2, storage_path('credentials/rsa/transfer/techcombank/2024/1pay_tcb_verify_sign_2.cer'));
 
             dd($aesPlaintText, $sign1, $sign2, $verify1, $verify2);
         }

Một số lỗi có thể gặp

"Warning: the ECDSA host key for 'github.com' differs from the key for the IP address" issue

development/system/git.txt · Last modified: 2024/08/15 09:03 by tungnt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki