Skip to content

Instantly share code, notes, and snippets.

@masukomi
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masukomi/4889766e1520ed3cbac4 to your computer and use it in GitHub Desktop.
Save masukomi/4889766e1520ed3cbac4 to your computer and use it in GitHub Desktop.
attempting to push to a git repo without doing a checkout
# first create a bare repo
git init --bare test_origin.git
# now create a repo that will push to it
git init test_1
Initialized empty Git repository in /Users/masukomi/workspace/temp/test_1/.git/
cd test_1
echo "test file 1 content" > test1.txt
git add -A
git commit -m "Test file 1 commit"
# add the bare repo as a remote...
git remote add origin ../test_origin.git
# and push to it
git push origin master
# set up a second repo
cd ../
git init test_2
cd test_2
echo "test file 2 content" > test2.txt
git add -A
git commit -m "Test file 2 commit"
# add the remote repo
git remote add origin ../test_origin.git
# PUSHING TO IT WILL FAIL WITHOUT A PULL
# IN PREVIOUS VERSIONS OF GIT THIS WAS
# POSSIBLE AS LONG AS IT DIDN'T CONFLICT
git push origin master
To ../test_origin.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '../test_origin.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment