[git-users] How come forced push resulted in other branch being moved back?

2014-03-13 Thread Yuri Kanivetsky
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.


Re: [git-users] How come forced push resulted in other branch being moved back?

2014-03-13 Thread Philip Oakley
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.


Re: [git-users] How come forced push resulted in other branch being moved back?

2014-03-13 Thread Yuri Kanivetsky
Philip, none of the commits were lost. It's just that the master now points
to the wrong commit. Also, it appears I misinterpreted the results of my
script. It shows what might have happened. Supposedly, there were two
things that made that happen: push.default were set to matching and master
being set to some commit in the past. I slightly changed my script so that
it would reproduce situation better:

#!/usr/bin/env bash
set -eu
rm -rf 1 2 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
echo 3 3  git add 3  git ci -m 3
git co -b devel
echo 4d 4d  git add 4d  git ci -m 4d
echo 5d 5d  git add 5d  git ci -m 5d
git co master
echo 4m 4m  git add 4m  git ci -m 4m
echo 5m 5m  git add 5m  git ci -m 5m

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~3
git checkout devel
git rebase origin/master
git config push.default matching
git push -f

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


And here's the output:

...
* ed124e4 (HEAD, master) 5m
* 63c82f6 4m
| * 2a3b850 (devel) 5d
| * 1c1c1bf 4d
|/
* e7ce151 3
* 12469e6 2
* 06a5068 1
...
* 110a7c6 (devel) 5d
* 286fad4 4d
* ed124e4 5m
* 63c82f6 4m
* e7ce151 3
* 12469e6 (HEAD, master) 2
* 06a5068 1


On Fri, Mar 14, 2014 at 12:46 AM, Philip Oakley philipoak...@iee.orgwrote:

  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 yuri.kanivet...@gmail.com
 *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.