Git Commands Guide - Ticket Booking Project Use
Case
p Command Definition When to Use Story Example
git init Creates an empty Git repository in your folder.
Starting a new project. You create the ticket-booking proje
git status Shows state of working directory & staging
Before
area.committing. Check which files are new or modi
git add <file> / git add . Moves changes to staging area. Before committing changes. Stage all new files.
git commit -m 'msg' Saves staged changes as a snapshot. After staging changes. Commit initial website files.
git remote add origin <url> Links local repo to remote. Before first push. Connect to GitHub repo.
git push -u origin main Uploads local commits to remote. Share code with others. Push main branch to GitHub.
git clone <url> Copies remote repo locally. Joining existing project. Teammate clones your repo.
git branch feature-login Creates a new branch. Work on features separately. Create login branch.
git checkout <branch> Switches to another branch. To work on/test that branch. Switch to login branch.
git merge feature-login Combines changes from another branch.Feature finished & tested. Merge login into main.
Resolve conflicts + git add +
Fixes
git commit
merge conflicts manually. When Git can't merge automatically.
Resolve app.js conflict.
git log Shows commit history. Check past commits. See when login was added.
git diff Shows file changes. Before committing. Review changes before push.
git pull origin main Fetches & merges remote changes. Stay updated. Pull teammate's payment fix.
git stash / git stash pop Temporarily saves changes. Switch branches quickly. Stash changes for hotfix.
git reset --hard <commit> Moves branch to specific commit, discards
Undo
changes.
commits. Go back to stable commit.
git cherry-pick <commit> Applies specific commit from another branch.
Bring one change only. Cherry-pick bug fix.
git tag v1.0 Marks a commit as a release. Publish stable version. Tag first production release.
git branch -d <branch> Deletes branch. After merging. Delete login branch.
git revert <commit> Creates commit undoing changes. Undo safely without losing history.
Revert bad CSS change.