Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...