1

Hey cause of the Corona crisis, I don't have access to the remote git repository cause the repository is on the local network of my company. So we work on local copies of the repository. Now my collegae created a new branch and added 3 commits to this branch. How do I create this branch and add the 3 commits to my local repository? I figured out to make the patches for the commits, but how do I create a new branch that is identical to the branch of my collegae? Does it just have to be the same name or is it more complicated than that? Once this crisis is over, idea is to push these changes to the remote repository.

Nico Haegens
  • 155
  • 1
  • 10
  • 2
    I feel like that's a bad idea. The commit hashes of the "ghosts" you create won't be the same as your collab, so they won't "merge" and disappear. Ask your colleague to send you a zipped copy of the archive, and fetch the commits you need from there. – Daemon Painter Apr 09 '20 at 08:47
  • https://stackoverflow.com/q/49101425/7976758 – phd Apr 09 '20 at 11:46

1 Answers1

1

Ask your colleague to run the following command

> git format-patch -3
0001-a.patch
0002-b.patch
0003-c.patch

This will create a list of patch files. Ask him to send it over to you. You can then apply these patch in serial order and you'll have identical changes in your branch.

Pankaj Singhal
  • 15,283
  • 9
  • 47
  • 86
  • Also hunt up `git send-email`. The entirety of linux kernel development runs on this. – jthill Apr 09 '20 at 09:05
  • So if I make a new branch with an identical name as my collegae's, apply the patches my collegae sends me, there won't be a problem when I push this code to the remote repository? – Nico Haegens Apr 09 '20 at 09:07
  • The commits you apply (you can do it with `git am`, for "apply mailed patch", that two-letter command name is a pretty good hint of how heavily used it is in common workflows) will have their original authors and you as the committer, so in case something goes wrong everyone can hunt you down and kill you, but that's the only difference between the commits in your repo and the ones in your colleague's. For sneakernetting pulls and pushes, use bundles or just open a vpn link and host a shared repo. – jthill Apr 09 '20 at 09:19
  • @jthill Thanks for the explanations on my behalf. :) – Pankaj Singhal Apr 09 '20 at 10:39