threads / discuss / 43005

Problem with two copies of same branch diverging

Subject: Problem with two copies of same branch diverging

## tl;dr

3 messages between Aug 4, 2016 and Aug 4, 2016.

replies: 2people: 2as markdown or json

Ed Greenberg· Aug 4, 2016, 15:08 UTC · lore
Hi, Thanks for reading my question.

I have two copies of code checked out at the same branch. Desktop and remote server.

I use an IDE that automatically SFTP transfers each save from the desktop to the remote server, so I can run my changes on the server environment.

At the end of the session, I commit the code on my desktop, do a git push to the repo.

When I look at the server, the code there is identical to what's on my desktop box and what I just comitted and pushed, but, of course, git status thinks it's all modified and wants me to either commit it or stash it. In fact, doing a git log on the server doesn't show my latest push. So I need to pull the changes, but I can't because I have pending stuff.

What's a good git workflow for this save-upload-remote test cycle?
Thanks,
-- 
Ed Greenberg
Glens Falls, NY USA
Junio C Hamano· Aug 4, 2016, 17:28 UTC · re: Ed Greenberg · lore

Re: Problem with two copies of same branch diverging

Ed Greenberg <edg@greenberg.org> writes:
Show 8 quoted lines
> Hi, Thanks for reading my question.
>
> I have two copies of code checked out at the same branch. Desktop and
> remote server.
>
> I use an IDE that automatically SFTP transfers each save from the
> desktop to the remote server, so I can run my changes on the server
> environment.

You are syncing _ONLY_ the working tree state without syncing Git state at all, and that is why the server side gets confused. You have to stop doing that.

If you do not do any change on the server end, you can simply stop having a git repository there; just treat its directory as what it really is: a copy of the working tree, something akin to an extracted tarball.

If you do change on both, you probably are better off without the mechanism to copy working tree one-way that you currently have. Just push or fetch between the two repositories and integrate the local changes.

Having said all that.
> At the end of the session, I commit the code on my desktop, do a git
> push to the repo.
> When I look at the server, the code there is identical to what's on my
> desktop box and what I just comitted and pushed, but, of course, git
> status thinks it's all modified and wants me to either commit it or
> stash it.  

This is expected as pushing into the remote would not affect what is checked out, most importantly, the index. But this ...

> In fact, doing a git log on the server doesn't show my
> latest push.  

... indicates that you are not pushing to update the remote repository correctly. Once you get that part working correctly, after you push at the end of the session, you should be able to do "git reset" at the other side to tell Git to notice that the updated working tree files that were transferred behind its back are now in sync with what is supposed to be checked out.

Junio C Hamano· Aug 4, 2016, 17:57 UTC · lore

Re: Problem with two copies of same branch diverging

On Thu, Aug 4, 2016 at 10:50 AM, Ed Greenberg <edg@greenberg.org> wrote:
Show 10 quoted lines
> On 08/04/2016 01:28 PM, Junio C Hamano wrote:
>>
>> ... indicates that you are not pushing to update the remote
>> repository correctly.  Once you get that part working correctly,
>> after you push at the end of the session, you should be able to do
>> "git reset" at the other side to tell Git to notice that the updated
>> working tree files that were transferred behind its back are now in
>> sync with what is supposed to be checked out.
>
> If this is the case, why do my fresh clones contain the most recent commit?

Exactly. Why does your "push" not result in "git log" to show the most recent commit? Once you solve that, "git reset" would do the right thing, I would think, just like a fresh clone shows the latest. The thing is, that I didn't quite find out what your "push" is doing wrong in your original message.

← back to recent threads