Octopress - 源分支突然向主站推进



问题出现了不久前:

$ git push origin source
To git@github.com:Loremaster/Loremaster.github.io.git
 ! [rejected]        source -> master (fetch first)
error: failed to push some refs to 'git@github.com:Loremaster/Loremaster.github.io.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
当我推送当前的源分支

时,它突然想将其推送到主分支(这是错误的,我想将本地源分支推送到远程源分支)。我记得我以前没有这样的问题,但现在我遇到了。当我部署我的博客时,一切正常(它已部署到主服务器),但我根本无法更新我的源代码。解决这个问题的最佳方法是什么?

这里也是git remote

$ git remote -v
octopress   git://github.com/imathis/octopress.git (fetch)
octopress   git://github.com/imathis/octopress.git (push)
origin  git@github.com:Loremaster/Loremaster.github.io.git (fetch)
origin  git@github.com:Loremaster/Loremaster.github.io.git (push)

这是git config --get-regexp remote

$ git config --get-regexp remote
remote.octopress.url git://github.com/imathis/octopress.git
remote.octopress.fetch +refs/heads/*:refs/remotes/octopress/*
branch.source.remote origin
remote.origin.url git@github.com:Loremaster/Loremaster.github.io.git
remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

$ git branch -avvv
* source                                  3eb4c8d [origin/master] Grammar fix.
  remotes/octopress/2.5                   5a6b8e4 Merge pull request #1378 from librehat/patch-1
  remotes/octopress/2.5-simplify-rakefile 277f702 Move install and list tasks into separate files.
  remotes/octopress/3.0                   0b44a79 Merge branch '3.0' of github.com:imathis/octopress into 3.0
  remotes/octopress/HEAD                  -> octopress/master
  remotes/octopress/commander             d489676 Changed config tag to use standard var names (aesthetic)
  remotes/octopress/gh-pages              4381053 Fix missing 'blockquote' in example, closes #229
  remotes/octopress/guard                 7bdab0e Added javascript asset management and improved Rakefiles and configuration for themes and plugins. - Added Guard for file watching - Configs can be automatically reloaded - Static asset changes do not trigger Jekyll build - CommonJS modular js support proved by stich-rb - Javascript is concatenated and uglified - Environment variables toggle uglify and fingerprinting - New Jekyll plugin config_tag - New Jekyll plugin javascript_assets_tag - Added theme specific configurations - Custome Jekyll Guard to the rescue - Install, Generate, Watch, and Preview work with Guard now. - Now configs are no longer tracked by Octopress, only theme defauts are. - Console messages can be colorized. - misc config reorganization and improvements
  remotes/octopress/jekyll-1-3            fc73997 Jekyll now ships with this method in Site, use it!
  remotes/octopress/linklog               1750830 Merge pull request #800 from mxmerz/linklog
  remotes/octopress/master                78defff Merge pull request #1443 from wickedshimmy/patch-1
  remotes/octopress/migrator              9b59940 migrating 'source' and 'sass'
  remotes/octopress/refactor_with_tests   8fe52e1 cucumber tests
  remotes/octopress/rubygemcli            9f54cbd Add plugin-include-array to core plugins.
  remotes/octopress/site                  53b2df0 Merge pull request #1252 from kendaleiv/patch-1
  remotes/octopress/site-2.1              98bd6c9 Merge pull request #1374 from imathis/site
  remotes/origin/master                   3eb4c8d Grammar fix.
  remotes/origin/source                   251a4d4 Small addition.
git remote并不是

这里唯一的因素。
git branch -avvv有助于查看哪个分支与远程跟踪分支相关联:它显示现在源与远程跟踪分支相关联origin/master而不是origin/source

您可以使用以下命令重置本地分支source的远程跟踪分支:

git branch -u origin/source source

请参阅"使现有 Git 分支跟踪远程分支?

然后,如果git config push.default设置为 simple(对于 Git 1.9+),一个简单的git push(在 source 分支上签出时)就足够了。

最新更新