Git basics - Pushing files to Remote
git add .
git commit -m 'Message'
git push origin master
Git reset local changes
git reset --hard HEAD
git clean -f -x -d -n
Git reset local changes before push
git reset --hard HEAD~1
Check existing remote URL
git remote -v
Git add remote URL
git remote add origin git@github.com:username/repo.git
Git change remote URL
git remote set-url origin git@github.com:username/repo.git
Reset git add. before commit
git reset
Sync a fork Add Upstream
git remote add upstream git@github.com:username/repo.git // main form url
git fetch upstream // fetch upstream to local
git merge upstream/master //merge to master
git push origin master
See changes in file
git diff filename
Get latest commit hash
git rev-parse HEAD -- full hash
git rev-parse --short HEAD --> short hash
Back to previous branch
git checkout -
Create new branch in Local and push to origin
git checkout -b branch-name
git push origin branch-name
Revert Merge
git merge --abort
Rebasing
git rebase master
git push -f origin branch-name // -f is important here
Revert pushed rebase
git reflog
git reset --hard HEAD@{10}
git push -f origin branch-name
Delete local branch
git branch -d branch_name
git branch -D branch_name // force delete