git branch --set-upstream-to=upstream/branchname
git fetch upstream -n
git log --graph --oneline --all --decorate
git switch -
git branch –m new-name
git branch –m old-name new-name
git switch -c <new_branch_name>
git push origin :branch-name
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
git remote prune origin
git branch --list 'prefix/*' | xargs -r git branch -D
git diff COMMIT^!
or
git diff-tree -p COMMIT
git diff upstream/BRANCH YOUR_BRANCH --name-only
git diff --name-only --diff-filter=M
git diff --name-only --diff-filter=U
git commit --amend
git reset --soft HEAD^
git reset HEAD path/to/unwanted_file
git commit -c ORIG_HEAD
git add the_left_out_file
git commit --amend --no-edit
git reset --soft HEAD~1
git checkout main
git pull
git checkout -
git rebase main
\# rebase / resolve ... make alterations
git add . && git commit -c ORIG_HEAD
git tag -a v1.0 -m "My version 1.0"
git push --tags
git push --delete origin tagname
git tag new old
git tag -d old
git push origin :refs/tags/old
git push --tags
git stash save “Your stash message”.
git stash apply stash@{1}
git stash pop stash@{1}
git stash show // latest stash
git stash show stash@{1}
git checkout branchname -- filename.json
git rev-list -n 1 HEAD -- <file_path>
git checkout <deleting_commit>^ -- <file_path>