Create, share, and contribute to a Git repository without GitHub
October 26, 2015 - Git
Have you found yourself in a scenario where you can’t use GitHub or a shared server for exchanging Git contributions among a team? Well you’re in luck, because Git will easily allow you to work with a team of developers using old-fashioned SSH or e-mail exchanges of code.
The below steps will show you how to:
- Share your repository with others
- Allow others to make modifications (including addition/mods to binary files)
- Allow others to create a patch that they can send to you for inclusion in your own local repository.
The basic idea is, if everyone does their modifications in separate branches on their own versions of the original repository, and sends patches of their changes to the team regularly, then development still can be seamless without necessitating a central Git repo.
Share your existing local Git repository with teammates
First, create an archive file containing your entire repository, which you can share with your teammates.
NOTE: in the example below, we’ve navigated to the parent directory of our repository so we can create a tar file.
tar zcvf <username>-repo.tar.gz my_repo_directory/
Next, share your newly archived directory over e-mail, SSH, or some other method
Set up a work area using someone else’s shared Git repository
First, extract and set up your own repository from a tar-ball repository provided by someone else
tar zxvf <username>-repo.tar.gz
Next, create a new branch to do your work and modifications within
cd <username>-repo/ git checkout -b my_username_branch
Finally, perform your modifications or additions to the repository within the branch, and add/commit your changes to that branch.
Share your modifications with other teammates
Create a patch containing all your modifications (within a branch)
git format-patch master --stdout > username_patch_name.patch
Next, send your patch file to your teammates over e-mail
Apply a patch from one of your teammates, to your local repository
First, get a summary of the contents of the patch
git apply --stat username_patch_name.patch
Next, check to see if the patch yields any conflicts if merged with your current branch
git apply --check username_patch_name.patch
Merge the patch with your current branch
git am --signoff < username_patch_name.patch
Done! You’ve successfully gone through the steps to create, share, modify, and merge changes on a single Git repository without GitHub!