0

Our central Git server is down at the moment, and my working copy is out of date, I'm working from home today, and I'm trying to see if there's a way that I can get a colleague who has the latest history to email me equivalent data to a git pull origin master.

For the sake of argument, let's call the latest commit I have in my working copy of the master branch abcd1234. My colleague's working copy is up to date with the server, and latest commit in his working copy of the master branch is ef123456.

How can he email me a dataset that covers the history from abcd1234 to ef123456, and how can I apply it to my working copy? (And is this equivalent to a pull from the server? Or would I be getting myself into tricky territory?)

I tried looking at git-format-patch but it doesn't seem to have any examples of this type, and I'm paranoid about getting the syntax right -- if I don't have high confidence that I know what I'm doing, then I'll wait for the server to be back up, which might take a few days.


Hmm. Another stackoverflow issue mentioned that git-bundle is more appropriate. But I'm still not sure how to capture history of a branch from one rev-hash to another.

Jason S
  • 184,598
  • 164
  • 608
  • 970
  • The disadvantage of `git format-patch` is that you'll get different SHAs. Not a big deal if you always rebase anyway. – o11c Aug 30 '17 at 23:07
  • If you have a true VLAN, it's trivial to clone a git directory over ssh. – o11c Aug 30 '17 at 23:08

1 Answers1

1

If—this is a very big if—everything is smoothly linear and you are the right committer and some other things line up, it is possible to use git format-patch and git am to transfer these commits and even keep their original hash IDs. But you're much better off with git bundle, which essentially breaks git fetch into its constituent parts.

The Git documentation is pretty obscure. See instead How to use git-bundle for keeping development in sync? Use something that encodes the bundle data into a form suitable for transporting from computer A to computer B (scp, turn into emailed binary, or whatever it takes). Then just git fetch from the bundled data once it's on the target computer.

torek
  • 448,244
  • 59
  • 642
  • 775