Git global setup
git config --global user.name "xxx"
git config --global user.email "xxx@xxxx.com"
Create a new repository
git clone ssh://git@gitlab.xxx.com/xxx/sxxxxxx.git
cd sxxxxxx
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin ssh://git@gitlab.xxx.com/xxx/sxxxxxx.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin ssh://git@gitlab.xxx.com/xxx/sxxxxxx.git
git push -u origin --all
git push -u origin --tags
生成新的SSH密钥(Generating a new SSH key pair)
ssh-keygen -o -t rsa -C "your.email@example.com" -b 4096
添加SSH密钥到git的账户(Adding a SSH key to your GitLab account)
macOS:
pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):
xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:
type %userprofile%\.ssh\id_rsa.pub | clip
Git Bash on Windows / Windows PowerShell:
cat ~/.ssh/id_rsa.pub | clip