近期准备将一个项目开源到 GitHub 中, N-Sharding,.Net 版本的分库分表数据访问框架. 中间遇到了点小问题, 整理了一下.
1. GitHub 上 Create New Repos
2. 代码 Check In 到本地 Git Repos
3. Push 到 GitHub 远程 Repos
一, GitHub 上 Create New Repos:N-Sharding
2. 代码 Check In 到本地 Git Repos
3. Push 到 GitHub 远程 Repos
推送提示一下错误:
将分支推送到远程存储库时遇到错误: rejected Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes before pushing again.
- Error: failed to push some refs to 'https://github.com/*****/N-Sharding.git'
- Error: hint: Updates were rejected because the tip of your current branch is behind
- hint: its remote counterpart. Integrate the remote changes (e.g.
- hint: 'git pull ...') before pushing again.
- hint: See the 'Note about fast-forwards' in 'git push --help' for details.
看中间第三句话: Updates were rejected because the tip of your current branch is behind
说明本地分支是旧的, 远程 Master 分支要新. 为什么呢?
突然想起来, 在 GitHub 上 Create New Repos 时, 增加了 Readme.md. 本地没有这个文件.
一顿百度后: https://www.cnblogs.com/gzdaijie/p/5186516.html
解决方案:
1. 打开 Git Bash
2. Git 拉取最新的代码到本地, 一定要 rebase, 强制同步更新本地分支
Git pull --rebase origin master
关于 Git rebase, 可以参考: https://git-scm.com/docs/git-rebase
3. 推送 Push 到 Master 主分支
Git push -u origin master
Push 成功, 代码成功提交到 master.
以上, 分享给大家.
周国庆
2019/3/17
来源: https://www.cnblogs.com/tianqing/p/10545294.html