11

I'm using git in my project. Sometimes I need to share my modified changes with my colleagues or to different PC, but I don't want to push those changes. He will take my code and modify something and then will push that code. For now I manually give him file via mail or send in pen drive. I want this to be done via git. Can I do like git commit and then share without git push?

vivek nuna
  • 12,695
  • 7
  • 48
  • 123
  • 2
    Possible duplicate of [Git Workflow: Share code between computers without pushing to public repo](https://stackoverflow.com/questions/11419448/git-workflow-share-code-between-computers-without-pushing-to-public-repo) – Daksh Shah Jun 10 '17 at 19:59
  • Create a branch and push to the branch, get the colleague to checkout your branch – Laazo Jun 10 '17 at 19:59
  • Possible duplicate of [How to use git-bundle for keeping development in sync?](https://stackoverflow.com/questions/3635952/how-to-use-git-bundle-for-keeping-development-in-sync) – Raymond Chen Jun 10 '17 at 20:03
  • @Laazo I tried this, but for minor changes is it good practice to create separate brnach? – vivek nuna Jun 10 '17 at 20:03
  • It's good practice to create a branch for any changes that may leave the main branch unstable – Laazo Jun 10 '17 at 20:07
  • Possible duplicate of [How to share a git feature (or topic) branch with multiple developers](https://stackoverflow.com/questions/8496358/how-to-share-a-git-feature-or-topic-branch-with-multiple-developers) – Aaron_ab Jan 10 '19 at 10:25

1 Answers1

22

You can save the changes to a patch file with

git diff > /path/to/file.patch

This supposes that your changes are unstaged. Use git diff --cached if they are staged. I would not commit them, since your colleague is going to do that and you'll run into conflicts otherwise.

You can send this file via mail or whatever, and your colleague can apply those changes with

git apply /path/to/file.patch
Manuel Schmidt
  • 1,711
  • 1
  • 9
  • 18