git - theartusz/config GitHub Wiki

  • rename current branch
git branch -m <new-branch-name>
  • delete local branch
git branch -d <local branch name>
  • push current local branch to remote branch with same name if it doesn't exist
git push origin HEAD
  • remove commit if it wasn't pushed yet - [HEAD~1] - to 1 commit where HEAD is
git reset --soft HEAD~1
  • unstage change
git restore --staged <file>
  • change remote url
git remote set-url <remote-name> <new-remote-url>
  • list all remotes with urls
git remote -v

git config

git config --global user.name "Artur Ferfecki"
git config --global user.email "[email protected]"

git aliases

  • create alias in git:
git config --global alias.co checkout
git config --global alias.cob "checkout -b"
git config --global alias.cmm "commit -m"
git config --global alias.ap "add -p"
git config --global alias.poh "push origin HEAD -u"
git config --global alias.s status
  • delete git alias:
git config --global --unset alias.co
  • show aliases
vim ~/.gitconfig

create new tag version

  1. after commiting, creating pull request and merging to master branch you need to pull the latest version:
git pull origin master
  1. fetch all tags and branches from origin
git fetch
  1. check if the tags were correctly fetched:
git tag
  1. create the (annotated tag):
git tag -a <tag> -m "<tag message>"
  1. push tag to remote
git push origin <tag>
⚠️ **GitHub.com Fallback** ⚠️