Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
212 views
in Technique[技术] by (71.8m points)

git - How push directly to remote server just using push?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...