April 8, 2023
Basic Git Commands
Some must-knows
Git clone with token if the repo is private or need specific access
git clone https://<USERNAME>:<TOKEN>@github.com/<OWNER>/<REPOSITORY>.git
git config --global user.name example_user
git config --global user.email [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
git clone http://git.example.com/example_user/some-project.git
cd some-project
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
cd existing_folder
git init --initial-branch=main
git remote add origin http://git.example.com/example_user/some-project.git
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 http://git.example.com/example_user/some-project.git
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.
This is a companion discussion topic for the original entry at https://henrywithu.com/basic-git-commands/