Git Configurations
git config --global --list
git config --global user.name "Bradley Caravana"
git config --global user.email "[email protected]"
git config --global --unset user.name
git config --global --unset user.email
Git .ignore Syntax
Ignore a specific file: file
Ignore a specific file in the current directory or a hidden file: .file
Ignore all files with a specific extension: \*.ext
Ignore all files in a specific directory: dir/
Ignore all files in a specific subdirectory: dir/dir2/
Ignore all files with a certain extension in a subdirectory: dir/dir2/\*.ext
Recursively match all files with a certain extension in a subdirectory: dir/dir2/\*_/_.ext
Don't ignore a specific file :!file
Don't ignore all files with a specific extension: !\*.ext
Don't ignore all files in a specific directory :!dir/
Init / Clone a Git Repository
git init
git clone https://github.com/repo.git
git add file.txt
git add .
git commit -m "Commit message"
git commit --amend -m "New commit message"
git push
Status / Log
git status
git log
git show HEAD
Branches
git branch
git branch branch_name
git branch -m old_branch_name new_branch_name
git checkout -- file_name
git checkout branch_name
git checkout -b branch_name
git branch -d branch_name
git branch -D branch_name
git merge branch_name
git restore .
Remote Branches
git branch -r
git branch -a
git remote -v
git remote add -f origin https://github.com/repo.git
git remote prune origin
git branch --set-upstream-to=origin/master
git fetch
git pull
git cherry-pick commitid
git push
git push origin master
git push -u origin master
Branch Comparison
git diff master
git diff branch1..branch2