Git Fundamentals
Git is a distributed version control system created by Linus Torvalds in 2005. Understanding its core concepts — commits, branches, remotes, and the staging area — is essential for every developer regardless of the languages they use.
Essential Daily Commands
git status— See what has changedgit add -p— Stage changes interactively, chunk by chunkgit commit -m "message"— Commit staged changesgit log --oneline --graph— Visual branch historygit diff HEAD— See all uncommitted changes
Branching and Merging
Use git checkout -b feature/name to create and switch to a new branch. Use git merge --no-ff feature/name to merge with a merge commit, preserving history. git rebase creates a linear history by replaying commits on top of the target branch.
Recovery Commands
Made a mistake? git reset --soft HEAD~1 undoes the last commit but keeps changes staged. git stash temporarily shelves changes. git reflog shows a history of all HEAD movements and can recover seemingly lost commits.
Useful Aliases
Set git config --global alias.st status to shorten common commands. Aliases save significant time in workflows with frequent git operations.