GIT Command Lines
-
Switch to the existing branch:
git checkout <branch_name> -
Switch to a new branch:
git checkout -b <origin_brnach> <new_branch_name> -
Add all local changes to the local repository:
git add . -
Commit all local changes:
git commit -m"commit message"The standard commit if GitLab is connected with Jira Software:
git commit -m"CHD-86: Update code for contract API"CHD-86 is your task on Jira Software
-
Push commits to the remote repository:
git push -
Pull code from the remote repository:
git pull -
Merge your branch codes with the other branch (ex, develop):
git checkout <your_branch> git merge developIf it shows many conflicts, you should fix it!
-
Roll back to the specific commit code
Firstly, you should determine the commit that you want to roll back:
git log --onelineThe result will show:
git reset --hard <commit_hash>
For example, commit_hash is 256cd72, which you want to go back to.
(Optional) If you want to push your code to the remote repository:
git push origin --force
- Cherry pick
-
Create a new MR to revert a specific commit
Step 1: Switch to main branch (ex, develop)
git checkout developStep 2: Check out the new branch from develop
git checkout -b revert-ckt-413Step 3: Go to the GitLab or GitHub repository, view the commit you want to revert
For example, I had requested to create a new MR to revert CKT-413, which had been merged into develop. I will choose to commit that my leader had merged. (now at 14/08/2025)

Nhận xét
Đăng nhận xét