git常用命令

初始化(已有仓库)

git init
git remote add origin https://github.com/gogo-code/web-app-mall.git
git branch -M main
git push -u origin main

初始化(没有仓库)

git init
git add .
git commit -m “first commit”
git remote add origin https://github.com/gogo-code/web-app-mall.git
git branch -M main
git push -u origin main

创建分支并切换分支

git checkout -b left

查看分支

git branch

合并分支

git checkout main
git merge left
git push

git checkout left
git push -u origin left

撤销上次push

git reset –soft HEAD~1

删除远程分支

git push -d origin branch-name

删除远程仓库连接

git remote rm origin