GIT: How to push code to repository on remote ssh server

You can push to  git repository which is on remote ssh server using git. You can configure remote repository as a git remote to be able access quickly using remote(short) name.

To be able to pull and push changes to repository on remote ssh server you have to specify it using any one of the following URL format.

For Instance, if repository is located at  /opt/project, URL would be

ssh://user@server/opt/project

You can push changes using following syntax

git push ssh://user@server/opt/project  master

or

git push server master

Where,

server is remote configured using git remote  command
master is the branch to push

or, it can also be specified in scp-like syntax

For Instance, if repository is located at /opt/project, URL would be

user@server:/opt/project

You can push changes using following syntax

git push user@server:/opt/project  master

or

git push server master

Where,

server is remote configured using git remote  command
master is the branch to push

When you push changes, you will be prompted for the password. You can configure ssh keys to bypass password authentication when you push changes.

Leave a Reply

Your email address will not be published. Required fields are marked *