Op 31-3-2012 1:58, Pavel Sanda schreef:
sa...@lyx.org wrote:
Author: Pavel Sanda<sa...@lyx.org>
Date: Sat, 31 Mar 2012 01:09:21 +0200
New Commit: 612109bb6e5e61ba3c3693696f329eac3a288b5b

Merge branch 'master' of lyx:lyx

..if only I know how this happened...

You had made local commits onto your master branch. If you then do 'git pull'. It will fetch the commits from the master branch at the server and merge them with your local commits.

If you do 'git pull --rebase' it would have rebased your local commits instead of merging them.

Personally I really advice to always create a new branch to do your own development.

  $ git push
  Counting objects: 8, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (5/5), done.
  Writing objects: 100% (5/5), 767 bytes, done.
  Total 5 (delta 3), reused 0 (delta 0)
  To git@lyx:lyx
     fd597d2..612109b  master ->  master
      ! [rejected]        2.0.x ->  2.0.x (non-fast-forward)
   error: failed to push some refs to 'git@lyx:lyx'
   To prevent you from losing history, non-fast-forward updates were rejected
   Merge the remote changes (e.g. 'git pull') before pushing again.  See the
   'Note about fast-forwards' section of 'git push --help' for details.

I would like to get rid of  ! [rejected] line and I guess there are at
least three possibilities:
a) push master only
b) pull 2.0.x before pushing (without checkout to 2.0.x in between)
c) stop tracking 2.0.x altogether


$ git push origin master

given that the remote is called 'origin'. See 'git remote -v'.


$ git config push.default current
$ git push

From now on, 'git push' will by default only try to push the branch you are on if there is a matching branch at the server.


$ git config push.default upstream

From now on, 'git push' will by default try to push the branch you are on if the upstream branch has a matching branch at the server.

b) I think this is not possible. A sort of possibly dangerous hack to do this is:

$ cp .git/refs/remotes/origin/2.0.x .git/refs/heads

This will just let the 2.0.x branch point to the same commit as the 2.0.x branch at the server.


$ git branch -D 2.0.x


$ git branch -m 2.0.x my2.0.x

If you still want to have a 2.0.x branch you can just give it a different name as the default for 'git push' is to push the branches which have a upstream branch with the same name (i.e. the default is 'git config push.default matching').


Reply via email to