2

I'm sure it's a dumb question, but I've never used git before. I'm using the git extension for Visual Studio 2019, cloned a remote repository, created a new local branch and created/modified some files. I don't want to push my local changes to the remote server, but send my local changes to a research fellow. Is there a way to send him only the newly added/modified files?

0xbadf00d
  • 17,405
  • 15
  • 67
  • 107

1 Answers1

2

Depending on the type of connectivity which exists between your workstation and your research fellow, you could simply bundle your repo.

Bundle only your branch (especially is the repo is huge)

git bundle create ../abundle yourBranch

Or even with less commits (very small bundle, assuming yourBranch comes from master)

git bundle create ../aBundle master..yourBranch

That will give you one file, which is easy to copy around/send to your colleague.
Said colleague will be able to fetch from it, getting your branch in the process.

The other approach is to generate a patch from your branch (that would hide the history of all commits in that branch though)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you for your answer. Say my local branch is called "local-branch". Do I need to invoke the bundle command (in the local repository folder) as `git bundle create local-branch.bundle master`? How can I verify what the created bundle contains? – 0xbadf00d Apr 20 '20 at 06:51
  • @0xbadf00d Unless your repository is huge, I would not bother and bundle everything: `git bundle create ../local-branch.bundle --all`. To check, you can simply clone that bundle elsewhere (`git clone local-branch.bundle`: you can clone from a bundle *file*) and do a `git branch -avvv`: you will see your branch in there. – VonC Apr 20 '20 at 06:54
  • Unfortunately, the repository *is* huge. – 0xbadf00d Apr 20 '20 at 08:36
  • @0xbadf00d OK: you can bundle your branch only. I have edited the answer accordingly. – VonC Apr 20 '20 at 08:41
  • Thanks for the edit. `git bundle create ../abundle -- local-branch` yields the error "rev-list died". – 0xbadf00d Apr 20 '20 at 08:55
  • @0xbadf00d What version of Git are you using? – VonC Apr 20 '20 at 09:02
  • @0xbadf00d Sorry, I realized I included '`--`' which are not needed here. I have edited the answer. – VonC Apr 20 '20 at 09:03