push existed local repo

  1. 现有仓库提交到github
    1. 纯新建项目push
    2. push已存在项目

现有仓库提交到github

纯新建项目push

echo "# licenseGenerator" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/SenRanja/licenseGenerator.git
git push -u origin master

push已存在项目

先做的:如果你手贱,github创建项目的时候,新建了什么license、readme有的没的的东西,本地push之前,得先git pull 一下:

git pull github master --allow-unrelated-histories

(git pull 远程名字 远程分支, 后面的 –allow-unreleated-histories ,比如你手贱新建了license,你git pull 的时候会拒绝,因为github新建项目弄的license有第一次的commit,和你本地历史对不上merge默认不允许,所以你得手动指定)

比如,如果本地gitea已经有项目了,应该是推送此处。
比如,我的evo系统,在本地已经推送gitea,默认的远程地址名字 origin 必须重命名。

git remote add origin https://github.com/SenRanja/licenseGenerator.git

git branch -M master

(git branch -M 命令用于重命名当前分支。具体来说,-M 选项告诉 Git 强制重命名分支,即使新的分支名与已存在的分支名冲突也会强制执行。这个命令的常见用途是将当前分支重命名为一个新的分支名。)

git push -u origin master

更改origin的远程名字的命令如下:

git remote add github https://github.com/SenRanja/licenseGenerator.git

git branch -M master

(强行将现在所在分支,重命名为 master 分支)

git push -u github master

(将本地的master分支代码提交到 github 的远程链接上)


Welcome to point out the mistakes and faults!