git 常用命令

40 阅读1分钟

git把一个新的项目传送到github或者码云上

git init
git add .
git commit -m "first commit"
git branch -M main  # 若分支是 master,替换 main 为 master
git remote add origin https://github.com/********
git push -u origin main  # 若分支是 master,替换 main 为 master

git克隆一个项目到本地 克隆的好处是直接包含了git信息,不需要自己remote add origin

git clone https://github.com/********

git传送已经绑定好github远程仓库的项目,只是更新远程仓库内容

git pull --rebase origin main # 若分支是 master,替换 main 为 master
git add .
git commit -m "first commit"
git branch -M main  # 若分支是 master,替换 main 为 master
git push -u origin main  #这一步有时推送不上去,是因为网络在国外的原因;还有一个原因是使用了vpn代理,需要清理vpn代理残留:git config --global --unset http.proxy 和 git config --global --unset https.proxy