Repository for Ideas & Research
Open Source GIS, Hydrologic Modeling, Optimization
Tags: ,

How to push to a non-bare git repository

1   Just once

On the remote machine

# create a new non-bare git repository
git init repo
# create and checkout a temporary branch
cd repo
git checkout -b tmp

On the local machine

# push to the new repository on the remote machine
git push --set-upstream remote_machine:repo master

On the remote machine

# checkout master
git checkout master
# tmp branch doesn't exist anymore
git branch -a

2   Allow git push to update the current remote branch

On the remote machine

# create a new non-bare git repository
git init repo
# configure receive.denyCurrentBranch to updateInstead
cd repo
git config --local receive.denyCurrentBranch updateInstead

On the local machine

# push to the new repository on the remote machine
git push --set-upstream remote_machine:repo master