Begin with the distribution’s git package on Rocky Linux 9. It keeps installation, updates and security fixes within the operating system’s package management process. Check the executable and account settings before creating the first repository.
This article is based on Rocky Linux 9 and a regular sudo-capable account. The actual verification was done by installing the package in the Rocky Linux 9 container and using the Git command. This is separate from records that test systemd or the desktop screen.
Git · GitOps All Series · 03 / 24
On this page
1. Check the operating system and package source
cat /etc/os-release
uname -m
sudo dnf repolist
sudo dnf info git
sudo dnf install -y git openssh-clients
git --version
command -v git
dnf info is used to check information about the package to be installed or installed. If the repository connection fails, check the DNS, proxy, and repository URL rather than changing Git settings first. The resulting install for this lab was Git 2.52.0; patch versions may vary depending on the Rocky release you are using and the state of your repository.
This series uses git switch, git restore, and git init -b main. In older environments, make sure the first two commands use Git 2.23 or higher, and the last option uses Git 2.28 or higher. If you need to upgrade for features, first review your distribution’s support path and scope of impact.
2. Git work is performed using a general account.
id
mkdir -p ~/git-lab
cd ~/git-lab
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --list --show-origin
I used sudo to install packages, but I don’t use it to create or commit repositories. Repeating sudo git commit may result in different author settings or make part of .git owned by root. It is best to place your work folder under your homepage to reduce confusion.
Global settings apply to this user’s repository. In projects that require a company email, overwrite it in the repository as follows: It doesn’t run before creating the repository.
# Run inside an existing repository.
git config user.email "work@example.com"
git config --show-origin --get user.email
3. Verify default behavior with new repository
Create the folder below with a name that does not overlap with existing projects. If there is already a folder with the same name, check the contents and select a different name.
cd ~/git-lab
mkdir rocky-check
cd rocky-check
git init -b main
printf '# Rocky Git lab\n' > README.md
git add README.md
git commit -m "Add Rocky lab README"
git status --short --branch
If you see main in the final output and there are no file changes, you have recorded your first commit. If Author identity unknown appears, check user.name and user.email in your current account again. You can complete this process even without a network connection.
Do not unconditionally dismiss ownership warnings
detected dubious ownership may appear when the owner of the repository and the executing user are different. First, check the actual ownership and mount configuration with id, ls -ld . .git. The solution will vary depending on whether it is a different user’s repository or the container’s UID is different.
Only shared repositories that you really trust can make exceptions with the exact path. Registering safe.directory '*' to trust all repositories is not recommended as the default setting. If it’s a file permission issue, hiding the warning won’t fix write permissions.
When updating, follow the package management flow.
sudo dnf check-update git
sudo dnf upgrade git
dnf check-update may return exit code 100 when updates are available. Handle that result separately from an actual failure in automation. Part 10 covers SSH access to an external Git server, and Part 14 covers using Rocky Linux as a Git server.
See Git’s Linux installation guide for package installation and git config: safe.directory for the ownership exception.
Previous · [Git and GitOps 02] Install Git on Windows 11: PowerShell and Git Bash · Next · [Git and GitOps 04] Install Git and Prepare a Repository on Ubuntu 24.04·Series list and example files



