هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
Set up Git once
Tell Git who you are. These values go into every commit.
git config --global user.name "Hosam Hani"
git config --global user.email "76218642+s0sta@users.noreply.github.com"
git config --global init.defaultBranch main
git config --global pull.rebase true
git config --global core.editor vim
git config --list --show-origin| Level | File | Option |
|---|---|---|
| System | /etc/gitconfig | --system |
| User | ~/.gitconfig | --global |
| Repository | .git/config | (default) |
في العمل
Use GitHub's noreply address in public repositories, so your real email is not in the history.
Know the three areas
A file moves through three places: the working tree (your files), the staging area (the next commit), the repository (saved commits).
Make good commits
One commit = one logical change, with a clear message: a short summary line, then (optional) why.
git add main.tf variables.tf
git add -p network.tf
git commit -m "Add web subnet and NSG"
git commit -am "Raise VM size for staging"
git commit --amend -m "Add web subnet, NSG and route table"| Option | Meaning |
|---|---|
git add -p | Choose parts of a file to stage |
git commit -a | Stage all changed tracked files and commit |
--amend | Replace the last commit (only before you push it) |
Look at the history
git log shows commits; git show one commit; git diff the changes.
git log --oneline --graph --decorate --all
git log -p -- main.tf
git log --author="Hosam" --since="2 weeks ago"
git show HEAD~1
git diff
git diff --staged
git diff main..feature -- modules/| Name | Means |
|---|---|
HEAD | The commit you are on |
HEAD~1, HEAD~2 | One / two commits before |
abc1234 | A commit by its short hash |
main..feature | Commits in feature that are not in main |
Ignore files
.gitignore lists files Git must never track: build output, logs, local settings, and secrets.
*.log
.env
.terraform/
*.tfstate*
__pycache__/
node_modules/انتبه
.gitignore does not remove a file that is already committed. git rm --cached FILE stops tracking it — but it stays in the old history. A committed secret must be rotated (changed), not only deleted.