-1

I got a remote git repository, I cloned it to my local repository, made local changes and when I push I got the message that I cant push to the master branch:

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

I read that if I change the branch it works, I do it and works, but I can't work like that; I need that when I push changes from local to remote repository the changes apply in the same time to the files on remote repository, I don't want to return to master branch, or merge branches.

I read too that I can use bare repositories, it doesn't work for me.

I see some videos where guys push directly to remote repository and just need to enter a passphrase, but I don't know how to do all that to work like that.

svick
  • 236,525
  • 50
  • 385
  • 514
  • Possible duplicate: http://stackoverflow.com/questions/3838727/git-post-receive-hook-for-website-staging. Even if it's not an exact duplicate, that's the correct answer. – Todd A. Jacobs Jun 05 '12 at 22:19

1 Answers1

1

I read too that I can use bare repositories, it doesn't work for me.

It should work for you though, if you get that the process described in Using Git to manage a web site is using a bare repo (to which you push to), with a post-receive hook:

$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive

The advantage, in your case, is that the hook can checkout any branch you need.

Note: the passphrase is likely related to using for a push address an ssh one, and using a private password-protected ssh key.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250