Change Timezone in Gitlab.
Viewing all available timezones.
Changing timezone in omnibus installations.
gitlab-ctl reconfigure
gitlab-ctl restart
Get project ID from gitlab:
Project -> Settings -> General -> General Project -> Expand -> Project ID.
# Gitlab API
# List protected branch of project:
curl --header "PRIVATE-TOKEN: 54KLSE-eN2hF1fAE48-" "http://gitlab-link.com/api/v4/projects/10/protected_branches"
# Protect branch:
curl --request POST --header "PRIVATE-TOKEN: 4KfHjd-eN2hF1fAE48-" "http://gitlab-link.com/api/v4/projects/10/protected_branches?name=QA&push_access_level=30&merge_access_level=30"
# Unprotect branch
curl --request DELETE --header "PRIVATE-TOKEN: 0dGHsfg-eN2hF1fAE48-" "http://gitlab-link.com/api/v4/projects/10/protected_branches/QA
Git Operations
## Initialize Git Repo.
sudo git init .
## Add Repository
sudo git remote add origin http://peoject-path-link
## pull Repository
sudo git fetch origin developer_branch:developer_branch
OR
sudo git pull origin developer_branch
## Remove branch from local repository
sudo git checkout developer_branch
sudo git branch -D developer_branch
## Remove branch from live gitlab
sudo git push origin --delete new_branch
## Save Credentials
sudo git config --global user.email "user@test.in"
sudo git config --global user.name "user"
## commit changes
sudo git commit -m "comments"
## Create new branch from developer branch
sudo git checkout -b new_branch developer_branch
## Merge changes to new branch
sudo git checkout developer_branch
sudo git merge --no-ff new_branch
## Set tag on new branch
sudo git checkout new_branch
sudo git tag "tag_name"
## Push new branch
sudo git push origin new_branch
Gitlab backup
Git cherry-pick
For example you want to merge one commit from master branch to QA branch.
Source : Master and Destination : QA
Steps :
1. Take pull of repository
git pull origin
2. List all commits of list specific time period commits
git log --oneline --since="2.days"
3. Copy Commit ID
4. Switch to other branch(QA) and take latest pull.
git checkout QA
git pull
5. apply commit to QA branch
git cherry-pick <commit_ID>
6. push changes to live branch
## git push
OR cherry-pick through Gitlab API
First get the private-token of your gitlab user.
1. Login gitlab -> Nagigate to "User settings".
2. Click "Access Tokens" from the left panel.
3. Enter name of access token, select expiry date, select all scopes and click on "Create personal Token".
4. Copy Token and place it on safe place.
List all commits:
curl --header "PRIVATE-TOKEN: <TOKEN>" "http://<gitlab-ip>/api/v4/projects/$project_id/repository/commits?ref_name=$branch" | jq '.[]' | jq -r '.short_id + " - " + .title'
Cherry-pick commit to specific branch:
curl --header "PRIVATE-TOKEN: <TOKEN>"
--form "branch=<master/QA>" "http://domain-name/api/v4/projects/<$project_id>/repository/commits/<$commit_ID>/cherry_pick"
Protected Branch Access Role change
You can't directly edit the Protected branch roles through API. there is trick to edit so.
you need to delete the role first and then recreate new with changed roles.
Below are the values for roles:
Developers - 30
Maintainers + Developers - 40
No one - 0
Remove Access to every one:
curl --request DELETE --header "PRIVATE-TOKEN: $Git-token" \
"$GITLAB-LINK/api/v4/projects/$ProjectID/protected_branches/master"
curl --request POST --header "PRIVATE-TOKEN: $GitlabToken" "$GITLAB-LINK/api/v4/projects/$PID/protected_branches?name=master&push_access_level=0&merge_access_level=0"
Re-create with Developers+Maintainers permission:
curl --request DELETE --header "PRIVATE-TOKEN: $Git-token" \
"$GITLAB-LINK/api/v4/projects/$ProjectID/protected_branches/master"
curl --request POST --header "PRIVATE-TOKEN: $GitlabToken" "$GITLAB-LINK/api/v4/projects/$PID/protected_branches?name=master&push_access_level=30&merge_access_level=30"
Gitlab Upgrade:
https://impurval.blogspot.com/2024/01/gitlab-community-version-upgrade-from.html
No comments:
Post a Comment