git中几种常见操作本地与远端仓库正确姿势

170 阅读1分钟

Git global setup

git config --global user.name "xxx"
git config --global user.email "xxx"

Create a new repository

git clone origin-adress
cd folder
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 origin-adress
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote rename origin old-origin-adress || git remote remove origin
git remote add origin new-origin-adress
git push -u origin --all
git push -u origin --tags