Git
Configuration
Set user name and email
sh
git config --global user.name "Your Name"
git config --global user.email "your@email.com"List current configuration
sh
git config --listRepository
Initialize a new repository
sh
git initClone a repository
sh
git clone <repo_url>Staging & Committing
Check status
sh
git statusAdd files to staging
sh
git add <file>Add all files
sh
git add -ACommit changes
sh
git commit -m "commit message"Branching
List branches
sh
git branchCreate new branch
sh
git checkout -b <branch_name>Switch branch
sh
git checkout <branch_name>Delete branch
sh
git branch -d <branch_name>Merging & Rebasing
Merge branch
sh
git merge <branch_name>Rebase branch
sh
git rebase <branch_name>Remote
List remotes
sh
git remote -vAdd remote
sh
git remote add <name> <url>Remove remote
sh
git remote remove <name>Pull & Push
Pull changes
sh
git pullPush changes
sh
git pushPush to specific branch
sh
git push origin <branch_name>Logs & Diffs
Show commit log
sh
git logShow log on one line per commit
sh
git log --onelineShow file changes
sh
git diffUndo
Unstage file
sh
git reset <file>Discard local changes
sh
git checkout -- <file>Amend last commit
sh
git commit --amendStash
Stash changes
sh
git stashList stashes
sh
git stash listApply last stash
sh
git stash applyTags
List tags
sh
git tagCreate tag
sh
git tag <tag_name>Push tags
sh
git push --tags