Git 仓库初始化常用命令

268人浏览 / 0人评论

Git 全局设置

git config --global user.name "username"
git config --global user.email "xxx@xxx.com"

创建一个新仓库

git clone 仓库URL
cd 文件夹
git switch --create main
touch README.md
git add README.md
git commit -m "add README"
git push --set-upstream origin main

推送现有文件夹

cd existing_folder
git init --initial-branch=main
git remote add origin 仓库URL
git add .
git commit -m "Initial commit"
git push --set-upstream origin main

推送现有的 Git 仓库

cd existing_repo
git remote rename origin old-origin
git remote add origin 仓库URL
git push --set-upstream origin --all
git push --set-upstream origin --tags

全部评论