0

I have an issue with my git repositories. My development branch "origin/master" (local) is up to date but the "stage/master" (remote) branch is behind.

Now i want the "stage/master" up to date with the origin/master branch.

enter image description here

How do i solve this issue?
I would like to keep the structure (not merging the two branches together)

Note: if it isn't obvious.. i'm quite new to git

  • Have you pushed to this remote previously? – e.doroskevic Aug 02 '16 at 14:40
  • origin/master and stage/master are two separate branches, they have the same name "master" but on two different connections "origin" and "stage". It is not common to do this. Could you clarify what you are trying to do? I'm not quite understand. – Klaus Aug 02 '16 at 14:41
  • A note on your terminology - `origin` and `stage` are remotes, so both `origin/master` and `stage/master` are remote tracking branches. Your local branch is simply `master`. – Dan Lowe Aug 02 '16 at 14:43
  • Yes, all the purple dots are commits that has been pushed to the remote. – Anton Bollen Forsberg Aug 02 '16 at 14:43
  • Sorry i'm confusing you guys. I have a server that has two separate remote repos. one for staging and one for "development". The development remote branch is named "origin/master" and the "stage" branch is obviously the stage/master. If i want to push my work to the stage-repo i simply push to that branch. And vice versa. – Anton Bollen Forsberg Aug 02 '16 at 14:48
  • It's not clear to me what the contents of these two branches are, but you probably do not want `git push -f`, that is a bad idea in 95% of cases unless you are really sure of what you're doing. You say you don't want to merge. In that case you likely want to do one or more `cherry-pick` to get your changes into the other branch. That will not merge them, but will apply the changes from one into the other. Take a look [here](http://stackoverflow.com/questions/1670970/how-to-cherry-pick-multiple-commits) – Dan Lowe Aug 02 '16 at 14:52
  • @DanLowe thank you! i will take a look on cherry-pick. – Anton Bollen Forsberg Aug 02 '16 at 14:57
  • @DanLowe it turned out i had to merge the branches anyway. Now (after some merge conflicts) it works. Thanks for your help! – Anton Bollen Forsberg Aug 03 '16 at 12:44

1 Answers1

-1

You can do that on terminal :

git checkout master #if you are not on it
git push -f stage master

But be sure of what you do, you can't revert. It look like stage/master have some commit, is it possible somebody else has work on it ? if this is the case, you will erase his work.

Edit : if you want to keep the work on stage/master you have to merge it, then you push it on you origin/master and after all your repos will be synced.

jibe
  • 578
  • 1
  • 4
  • 12
  • No, i'm the only one working on this right now. So, the files in origin/master will still be intact as they are? – Anton Bollen Forsberg Aug 02 '16 at 14:39
  • you can see what was modified by doing a ``git log stage/master~5..stage/master``. I strongly suggest you to do that before push -f – jibe Aug 02 '16 at 14:42
  • 1
    @AntonBollenForsberg `-f` is quite often destructive. Based on your screenshot above, if you run this command, your existing `stage/master` (purple dots) will be destroyed and replaced with `master`, the series of blue dots above the purple dots. – Dan Lowe Aug 02 '16 at 14:45
  • Okey, then i think i have to go for another option. – Anton Bollen Forsberg Aug 02 '16 at 14:49
  • @AntonBollenForsberg: if you do want master = origin/master = stage/master, you have to check what was commited on stage/master and then there is 2 options. If this is important, you will have to merge it on your local master and then you can update "normaly" your remotes. Otherwise, if this is junk then you can push force. – jibe Aug 02 '16 at 14:58
  • @jibe it turned out i had to merge the branches anyway. Now (after many merge conflicts) it works. Thanks for your help! – Anton Bollen Forsberg Aug 03 '16 at 12:44