Command | Purpose |
---|---|
git init | Initialize a new local repository |
git clone [URL] | Clone remote repository |
git remote add origin [URL] | Link local repo to remote |
git config --global user.name "Your Name" | Set global username |
git config --global user.email "you@example.com" | Set global email |
Command | Purpose |
---|---|
git status | Check current repo state |
git add [file] | Stage file for commit |
git commit -m "message" | Commit staged changes |
git log | View commit history |
git diff | Show changes not yet staged |
Command | Purpose |
---|---|
git branch | List branches |
git branch [name] | Create new branch |
git checkout [name] | Switch to branch |
git merge [name] | Merge branch into current |
git branch -d [name] | Delete branch |
Command | Purpose |
---|---|
git push origin [branch] | Push commits to remote |
git pull origin [branch] | Fetch and merge from remote |
git fetch | Download changes without merging |
git rebase [branch] | Reapply commits on top of another branch |