Why and what
Git stores commits representing snapshots and history. A working tree contains current files, the index stages the next commit and a repository stores history. A remote is another repository location, not a backup guarantee. Branches are movable references to commits; merging combines histories while rebasing rewrites commit ancestry.
Local lab
mkdir -p ~/academy/git-lab
cd ~/academy/git-lab
git init
git config user.name 'Academy Student'
git config user.email 'student@example.com'
printf '<h1>Version one</h1>\n' > index.html
git add index.html
git commit -m 'Add first web page'
git switch -c improve-heading
printf '<h1>Cloud academy</h1>\n' > index.html
git diff
git add index.html
git commit -m 'Clarify page heading'
git log --oneline --graph --allThe identity settings are repository-local here. Configure a real authorized identity before pushing to a shared service. Inspect git status and git diff --staged before committing.
Collaboration flow
Create a remote repository you control, add it as origin, push a feature branch and open a pull request. Review purpose, diff, tests and operational impact. Protect the main branch using the host's controls. Resolve conflicts by understanding both changes, not blindly accepting one side.
Secrets and generated files
Add .env, private keys, dependency directories and sensitive state files to appropriate ignore rules before staging. Gitignore does not remove already tracked secrets. If a credential is committed, revoke/rotate it; deleting the visible line does not erase history or copies.
Undo safely
git restore file discards uncommitted changes in that file. git revert COMMIT creates a new inverse commit and suits shared history. Reset can move branch pointers and discard data depending on flags; do not use hard reset casually. Tag a known release and record its deployed commit SHA.
Assignment
Create two branches that edit the same line, merge in a disposable repository and resolve the conflict. Explain why a successful merge does not prove semantic correctness. Keep this lab local unless you intentionally create a remote.
Official reference
Ravindra’s Tip
Commit करने से पहले staged diff पढ़ो। गलत file और secret अक्सर जल्दी में git add करने से repository में पहुँचते हैं।
Interview and revision check
Why rotate a committed secret even after deleting it?
The old value remains in history or copies. Removing the visible line does not revoke the credential.
Ravindra Bagale · Cloud & DevOps Academy · Handbook and project downloads