All essential git commands with examples
git config --global user.name "Your Name"Configure your git username
git config --global user.email "you@example.com"Configure your git email
git config --listView all git configurations
git initInitialize a new git repository
git clone <url>Clone an existing repository
git clone -b <branch> <url>Clone a specific branch
git add <file>Stage a specific file
git add .Stage all changes
git commit -m "message"Commit staged changes
git commit --amendModify the last commit
git branchList all local branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <branch>Create and switch to new branch
git branch -d <branch>Delete a branch
git remote add origin <url>Add a remote repository
git push origin <branch>Push to remote
git push --forceForce push (use carefully)
git pullFetch and merge remote changes
git reset HEAD <file>Unstage a file
git reset --soft HEAD~1Undo last commit, keep changes
git checkout -- <file>Discard working directory changes
git revert <commit>Create a new commit that undoes a commit