2

The problem appeared a while ago:

$ 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.

When I push my current source branch it suddenly want to push it to the master branch (which is the wrong, I want to push local source branch to the remote source branch). As I remember I didn't have such problem before, but now I have it. When I deploy my blog then everything is ok (it is deployed to the master) but I simply can't update my source. What is the best way to fix that?

Here is also 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)

Here is 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/*

And

$ 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.
ExiRe
  • 4,727
  • 7
  • 47
  • 92

1 Answers1

4

git remote isn't the only factor here.
git branch -avvv would help to see what branch is associated to a remote tracking branch: it shows that now source is associated to the remote tracking branch origin/master instead of origin/source.

You can reset the remote tracking branch of your local branch source with:

git branch -u origin/source source

See "Make an existing Git branch track a remote branch?"

Then, provided git config push.default is set to simple (for Git 1.9+), a simple git push (while being checked out on the source branch) will be enough.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I tried your solution. So here is output for `git branch -u source source`: `warning: Not setting branch source as its own upstream.`. When I try to push: `git push` i get the error: `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'` – ExiRe Jan 26 '15 at 13:09
  • @ExiRe I have updated the answer: `git branch -u origin/source source` – VonC Jan 26 '15 at 14:09
  • "git branch -u origin/source source" fixed my problem too, thanks – uowzd01 Jan 30 '15 at 09:20