Sounds like the user had not fetched the latest commits from the remote so that 
her/his local copy of that remote was behind and after the rebase he had lost 
those commits relative to the true remote, so when he force pushed his rebased 
branches the remote was rolled back.

Philip
[sorry for the top post]
  ----- Original Message ----- 
  From: Yuri Kanivetsky 
  To: git-users@googlegroups.com 
  Sent: Thursday, March 13, 2014 9:51 PM
  Subject: [git-users] How come forced push resulted in other branch being 
moved back?


  In fact, that's not me who did this, so I can't be sure what exactly he did. 
He had master and devel branches. He rebased devel onto master branch and did 
`git push -f`. Supposedly, push.default was set to matching and both branches 
were pushed. But now in the remote repository master is several tens of commits 
earlier. I'm not sure if he did `git fetch` and which commit master pointed to 
at the moment, anyway I'll try to visualize what happened:


  * (origin/master)
  | * (devel)

  | |
  ...

  | * (origin/devel)

  | |
  ...

  | /
  *




  v (git rebase origin/master)




  * (devel)
  |
  ...
  * (origin/master)
  |

  ...

  | * (origin/devel)

  | |
  ...

  | /
  *




  v (git push -f)




  * (devel, origin/devel)
  |
  ...
  *
  |

  ...

  | * (previous origin/devel)

  | |
  ...

  | /
  *
  |
  ...
  |
  * (origin/master)
  |
  ...




  Also, I've got a hook reporting about each commit and I received a bunch of 
letters with subject "discarded commit (<commit message>)". I tried to 
reproduce it with the following script, but to no effect:




  #!/usr/bin/env bash
  set -eu
  rm -rf 1 1.git
  mkdir 1


  cd 1
  git init
  echo 1 >1 && git add 1 && git ci -m 1
  echo 2 >2 && git add 2 && git ci -m 2
  git co -b devel
  echo 3d >3d && git add 3d && git ci -m 3d
  echo 4d >4d && git add 4d && git ci -m 4d
  git co master
  echo 3m >3m && git add 3m && git ci -m 3m
  echo 4m >4m && git add 4m && git ci -m 4m


  cd ..
  git clone --bare 1 1.git
  rm -rf 1
  git clone 1.git 1


  cd 1.git
  git --no-pager log --oneline --decorate --graph master devel


  cd ../1
  git reset --hard HEAD~
  git checkout devel
  git reset --hard HEAD~
  echo 4d2 >4d2 && git add 4d2 && git ci -m 4d2
  git config push.default matching
  git push -f


  cd ../1.git
  git --no-pager log --oneline --decorate --graph master devel




  Then if I do `git fetch` in other repositories:




  * (master)
  |
  ...
  |
  * (origin/master)
  |
  | * (origin/devel)
  ...
  | /
  *




  v (git fetch)




  * (devel)
  |
  | * (master)
  ...
  | /
  * (previous origin/master)
  |
  ...

  |
  * (origin/master)




  And `git pull --rebase` says "Current branch master is up to date." But if I 
do `git pull --rebase` without `git fetch` first, that's what happens:




  * (master)
  |
  ...
  |
  * (origin/master)
  |
  | * (origin/devel)
  ...
  | /
  *




  v (git fetch)




  * (devel)
  |
  ...

  |
  * (previous origin/master)
  |
  | * (master)
  ...

  | /
  * (origin/master)




  Hope I made myself clear. And the question is what am I missing? How this 
could happen? Thanks in advance.

  -- 
  You received this message because you are subscribed to the Google Groups 
"Git for human beings" group.
  To unsubscribe from this group and stop receiving emails from it, send an 
email to git-users+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to