Ah thanks!

On Monday, December 19, 2016 at 6:19:05 PM UTC+10, Konstantin Khomoutov 
wrote:
>
> On Sun, 18 Dec 2016 23:12:36 -0800 (PST) 
> AD S <ad...@radianweb.com.au <javascript:>> wrote: 
>
> > I pushed some files to my remote server, same as I have always done 
> > for this project. I was expecting to have merge conflicts which I 
> > would fix but I got none. I checked the remote server and saw that my 
> > adjusted files had completely overwritten the files on that server, 
> > meaning that I have now lost heaps of work from other branches. 
> > 
> > Would anyone know what might have caused this? 
> > 
> > My steps were: 
> > 
> >    1. git add . 
> >    2. git commit 
> >    3. git push ${project} ${refspec} 
> >    4. git merge ${refspec} 
> >    5. git push ${project} ${server} 
>
> You appear to miss one crucial point about Git's interaction with 
> remote repositories: the `git push` operation does not fetch remote 
> changes -- only pushes yours. 
>
> Hence your step (3) merely sent your changes to the remote repository 
> where they were either accepted or rejected. 
>
> Before doing (4) you were supposed to get fetch the remote changes -- 
> to actually have stuff to merge your changes with. 
>
> It seems, that (4) was a no-op then, and from your 
> > my adjusted files had completely overwritten the files on that server 
> it appears that when doing (5), you instructed Git to do the so-called 
> "force push" (by passing that command the "-f" or "--force" 
> command-line option).  Force push literally means "throw away the 
> changes which would conflict with mine, and take those of mine 
> instead" (and hence you should never do this until absolutely 100% sure 
> about what you're doing). 
>
> So I'd say you're lacking a fair bit of knowledge regarding proper 
> workflow to be used with remote repositories.  If yes, yo need to cover 
> this gap.  Supposedly start with [1], and I'd also recommend reading [2] 
> then. 
>
> 1. https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches 
> 2. https://longair.net/blog/2009/04/16/git-fetch-and-merge/ 
>

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