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
?
Asked
Active
Viewed 1.3k times
18

Vivek Nuna
- 25,472
- 25
- 109
- 197
-
2Possible 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 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 Answers
36
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
- 2,178
- 2
- 15
- 19
-
-
@ShashwatKumar ,it uses a git mechanism to share and apply change sets without pushing to a repository, which is also a requirement of OP. – Manuel Schmidt Jun 10 '17 at 21:27
-
1