Home > Net >  Why doesn't github throw an error ! [remote rejected] master -> master (branch is currently
Why doesn't github throw an error ! [remote rejected] master -> master (branch is currently

Time:11-20

Suppose I do this.

Using github

  1. on local machine: git init testrepo

  2. on github: make a repo test.git pressing buttons in the web interface

  3. on local:

cd testrepo

git remote add origin https://github.com/Someuser/test.git

and then:

touch somefile

git add .

git commit -m 'first'

git push -u origin master

Everything is fine and I have my somefile syncronized to github repo.

Using a remote server

  1. on local machine: git init testrepo

  2. on remote machine:

mkdir test.git

  1. on local:

cd testrepo

git remote add origin remotemachine:~/test.git

and then:

touch somefile

git add .

git commit -m 'first'

git push -u origin master

Oh, no!..

Error message.

! [remote rejected] master -> master (branch is currently checked out)

Everything looks the same. Why does github act differently?

Optionally, what is the remedy? Optionally - because you'll see a bunch of proposed solutions in the below question but none of them is accepted answer.

I am aware of this question Git push error '[remote rejected] master -> master (branch is currently checked out)'

However it doesn't answer my question.

CodePudding user response:

Everything looks the same.

Only looks. Really the situations are different.

Why does github act differently?

Because at GiHub no branches are checked out. Repositories at GitHub are bare (no working trees).

The bottom line: if a remote repository is intended to be pushed to it should be bare.

See these questions and answers about bare repositories:

What's the -practical- difference between a Bare and non-Bare repository?

What is the difference between "git init" and "git init --bare"?

  • Related