Git shortcut and cheatsheet
Created At :
Git command
Git command basic
# add all edited files
git add *
# commit
git commit -m "changes"
# push to certain branch
git push
git push origin
Git command branch
Show branch
# show current branch
git status
# show local branches
git branch
git branch -r
git branch --remote
git branch -a
git branch --all
Switch branch
git checkout --track origin/my-branch-name
git checkout my-branch-name
Edit branch
# create
git checkout -b new-branch-name
# which equals
git branch new-branch-name
git checkout new-branch-name
# delete
git branch -d my-branch-name
# force delete
git branch -D my-branch-name
# delete remote
git push origin --delete my-branch-name
# rename
git branch -m <oldname> <newname>
# rename current
git branch -m <newname>
# force rename
git branch -M <oldname> <newname>
# rename remote branch
git push origin localBranchName:remoteBranchName
Git command remote
# remote infomation
git remote -v
# change remote url
git remote set-url origin new.git.url/here
git push -u origin master