[racket-dev] Git

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Jan 7 16:33:16 EST 2011

Four hours ago, Stevie Strickland wrote:
> On Jan 7, 2011, at 12:29 PM, Robby Findler wrote:
> > Then, on the laptop, I did a git pull, and I ended up with the
> > commits back in the original order and a merge commit afterwards
> > but I would rather just have my state be like the server's was.
> Then don't do git pull.  That not only updates your remotes, but
> does a "git merge" (which will create a merge point if it's not a
> simple fast-forward, as you've seen here).  What you want to do is
> update your remotes using "git remote update", and then use "git
> reset --hard" to reset to the server's master (or whichever branch
> off of which you're working).

Yes, a hard reset is the simplest thing to do, basically dumping
everything you had on the laptop and continuing from where you were on
the desktop.


Four hours ago, Robby Findler wrote:
> Even worse, I forget if I forgot to push some changes from laptop or
> not.

...that's the dangerous part -- a hard reset will make your master
branch be where the desktop was, and if you forgot to push a change
from the laptop then it will be lost.  Two ways to solve this:

* Use a rebase of the laptop's master on top of the desktop.  Usually,
  git can figure out changes that were already included and it will
  omit them, leaving you with only forgotten commits, if any.

> As far as my other question goes, I think that perhaps the right
> answer is just "don't forget".

* Yeah -- don't forget to push changes...  IOW, just do the hard reset
  thing.  This is practical, btw -- git maintains a "reflog" which
  logs where each branch was in the past (keeping information that
  goes back a month).  This means that when you do the hard reset, you
  still have the old commit sha1 in the reflog, so if you find out
  that some commits are missing, you can use the reflog to see where
  you were, and look for the missing commits.  (This is actually not
  as hard as it sounds.)  Git does do an occasional GC over the object
  store, but it considers the reflog as part of the active roots, so
  you *are* safe for some time.

> That is, when I go back to my laptop and I see that "git status"
> thinks that things are not up to date (ie, before doing a pull or
> 'git remote update'), then I should take my changes there and just
> plan to either kill them or put them off in a branch somewhere else,
> get the latest stuff from the server and then go from there.

Remember that creating a branch is *very* cheap, so you can just
create a new branch to point to where the master points, then do a
hard reset with the master while you have the other branch
conveniently available for comparisons etc.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.