…or create a new repository on the command line
echo "# demo" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:demo.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin git@github.com:demo.git
git branch -M main
git push -u origin main
Git push -u origin main
一般都是在我们项目中初次使用Git 进行远程提交 -u 的意思就是之后我们在想提交就只要使用 Git push 就行 如果不加这个-u的参数 之后每次提交都需要使用 Git push origin mian
添加-u参数后 可以使后续提交命令变得简洁
-u 命令就会把push后边的远程主机名origin和需要推送的分支main保存在本地的config中
之后使用中可以省略主机名和分支名,直接写:git push ,使用已经配置的参数推送
切换分支的时候,重新调用 -u 重新配置参数