0

I'm learning git and just experimenting, so there is not real reason I need to do this yet:

I tried running

git push path_to_local_repo master

form a different local repository.

I got this error:

enter image description here

Why is git angry?

cade galt
  • 3,843
  • 8
  • 32
  • 48
  • 1
    Possible duplicate of [What is this Git warning message when pushing changes to a remote repository?](http://stackoverflow.com/questions/804545/what-is-this-git-warning-message-when-pushing-changes-to-a-remote-repository) – ChrisGPT was on strike Nov 27 '15 at 14:25
  • The error message quite clearly states: "Refusing to update checked out branch" Ie. you need to check out another branch and then the operation would be possible, but a bit silly, as you'd be pushing the master branch onto itself. It would just say "Everything up to date" – Alderath Nov 27 '15 at 14:34
  • I believe the correct method will be to just copy the files. A repo is a directory, and it's scope is not aware of other repos on the filesystem. Interesting question though! – Selfish Nov 27 '15 at 14:59
  • I'm sure if it can be aware of remote repos it can be aware of local repos? – cade galt Nov 27 '15 at 15:01

2 Answers2

1

The problem is that you are trying to push to the currently checked-out branch in the other local git repo. Possible work-arounds: push to a different branch and then manually merge that branch into master

git push ~/root-working master:godaddy-master
cd ~/root-working
git merge --ff-only godaddy-master

or just go into the other folder and pull from there

cd ~/root-working
git pull ~/root-godaddy
tarleb
  • 19,863
  • 4
  • 51
  • 80
  • but it is completely O.K. to push and pull from non-bare repos I take it? – cade galt Nov 27 '15 at 15:04
  • Yes, absolutely. Git only doesn't want anybody to get confused, as the checked out files could be different than what's in the repo. So it just plain refuses to push. – tarleb Nov 27 '15 at 15:10
  • But still this is why bare repos are normally use to share files. – cade galt Nov 27 '15 at 16:35
0

You want to push a local repo to another remote repo, right?

If so:

git push [remote] branch_name
sTodorov
  • 5,435
  • 5
  • 35
  • 55