I'm an intermediate git user, and I'm trying to set something like this up:
My friend and I have a repository on github, and he has git credentials, and I have my own git credentials, but we also have a remote server which we would like to pull changes onto.
Is there a specific way we set this up? Or do I just make another normal git account for the server?
Also, we have a develop and a master branch, I would like to have two separate directories which default to either of these branches.
Essentially, either of us should be able to log in, navigate to dev or master, and do "git pull" without having to log into our git account, and have it naturally understand that it has to pull from dev if we're in the dev folder, or master if we are in the master folder.
I appreciate the help!
CodePudding user response:
There are two ways to handle deployment like this. The first is to have each of you have your own SSH key which is registered with GitHub and log into the server, forwarding your agent (with ssh -A
or an appropriate configuration option). Then, when you log in, you can push or pull with your SSH key using an SSH remote.
The other alternative is to use a deploy key, which is better if you want to perform automated Git operations. This is an SSH key that's specific to the repository and it's uploaded in the repository settings. This allows that key to have either read-only or read-write access to just that repository, which you can then use in whatever way you like.