Basic Git Commands

Some must-knows

Basic Git Commands
  • Git clone with token if the repo is private or need specific access
git clone https://<USERNAME>:<TOKEN><OWNER>/<REPOSITORY>.git
  • Git global setup
git config --global example_user
git config --global [email protected]
  • Git to store credentials in plaintext in a file (not recommended)
git config --global credential.helper cache
git config --global credential.helper store
  • Create a new repository
git clone
cd some-project
git switch -c main
git add
git commit -m "add README"
git push -u origin main
  • Push an existing folder
cd existing_folder
git init --initial-branch=main
git remote add origin
git add .
git commit -m "Initial commit"
git push -u origin main
  • Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin
git push -u origin --all
git push -u origin --tags
  • If you like to use mobile App for GitLab. You can try GitBlur on AppStore. Access Token is required. Go to User Settings -> Access Tokens -> Select scop and generate token.

Copyright statement: Unless otherwise stated, all articles on this blog adopt the CC BY-NC-SA 4.0 license agreement. For non-commercial reprints and citations, please indicate the author: Henry, and original article URL. For commercial reprints, please contact the author for authorization.