git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Howto request: going home in the middle of something?

From
APAndy Parkins <andyparkins@gmail.com>
Date
Oct 18, 2007, 11:29 UTC
Message-ID
<200710181229.07106.andyparkins@gmail.com>
In-Reply-To
<200710181144.22655.wielemak@science.uva.nl>
On Thursday 2007 October 18, Jan Wielemaker wrote:
Show 16 quoted lines
> I've somewhere seen it in a mail, but I can't find it anymore. I have a
> bare central (public) repository and clones on various machines I work
> on. We all know it, you're right in the middle of something and it is
> really time to go home. You want to pick up your work at home, but
> without pushing to the shared repository.
>
> I'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess
> Ideally I want "git stash" at work, transfer the stashed changes to my
> other machine and apply them.  How do I do that?
>
> Alternatively, I guess, one can commit at machine A, fetch the commit
> from machine A and continue. I'm still too uncertain about the remote
> access options to work this out properly, but it also feels less
> clean.
>
> How do you deal with this?

I have two remotes (typically) in my .git/config. One for the real central repository and one for the alternate computer. The two locations (say home and work) list the other as a remote.

So; before I go home I do this:
 git commit -b temp -a -m "Hold for transport home"
Then when I get home I do this:
 git fetch work
 git merge work/temp
 git reset HEAD^
 # code code code
 git commit -b temp -a -m "Hold for transport to work"
When I'm finished at home and want to carry on at work:
 git fetch --force home
 git merge home/temp
 git reset HEAD^
 # start coding for the day

Obviously if you do this repeatedly you'd need to tidy up the left over temp branches, or ensure that your remote configurations list "+" in the fetch lines. You can also use pushes instead of fetches if you're that way inclined, or you have a connection problem in one direction because of a firewall.

It's slightly inelegant but it does ensure that nothing is ever accidentally lost by overwriting new with newer, which happened a few times in the days when I used rsync for copying the working directory between computers.

Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Previous: Jing Xue
Message 11 of 11 in “Howto request: going home in the middle of something?”
  1. Jan WielemakerOct 18, 2007
  2. Johannes SixtOct 18, 2007
  3. Karl HasselströmOct 18, 2007
  4. Petr BaudisOct 18, 2007
  5. Jan WielemakerOct 22, 2007
  6. Johannes SchindelinOct 22, 2007
  7. Jing XueOct 23, 2007
  8. Jan WielemakerOct 23, 2007
  9. Matthias KestenholzOct 23, 2007
  10. Jing XueOct 24, 2007
  11. Andy ParkinsOct 18, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.