问题
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.
回答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.
来源:https://stackoverflow.com/questions/10905739/how-push-directly-to-remote-server-just-using-push