Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push commits to a remote Git repository which is separated by an air gap?

Tags:

git

My team and I work on different networks. We don't have an internet connection nor do we share the same network. Thus the only way we can transfer files is using thumbdrives.

The only way I can commit to the remote Git repository is if I use my colleague's computer which has network access to the Git server. What commands do I have to run for me to fetch, merge, then push my commits onto her computer, short of transferring my entire working directory over?

Like, say transfer only the commits that the remote server lacks.

EDIT: I forgot to mention the thumbdrive might get wiped periodically as part of security measures. Remote repo on thumbdrive is still a pretty good idea though!

like image 811
Cardin Avatar asked Jun 03 '15 07:06

Cardin


People also ask

How do I push commits to remote repository?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.

How do I push to a different remote branch?

In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.

How do I push changes to a git repository?

To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.


1 Answers

You can setup a git remote on a filesystem, so I assume if you mount your thumbdrive on their machine they could add you repo as a remote and merge in your changes

# Mount thumbdrive
# Add a remote to the filesystem
git remote add cardin_usb /Volumes/myusb # or whatever the usb path is

# pull in the changes
git fetch cardin_usb
# merge any branches as per normal eg
git checkout master
git merge cardin_usb/my_feature

Edit - just read you want to do the changes only. You could generate patches if you know the last commit the remote server has:

git format-patch lastServerCommit^..HEAD --stdout > new_changes.patch

Then transfer this via usb, and your coworker can submit.

like image 111
acanby Avatar answered Sep 19 '22 15:09

acanby