How do I add a remote Git repository to an Ubuntu Server?

git remote add
git server windows
git remove remote
what is a git server
install git server centos 7
git add remote branch
git server ubuntu
git create bare repository

I have created a Git repository on my Desktop machine (Windows 7) with:

git init
git add <all my files>
git commit -m "added my files"

Now I have installed a new Ubuntu Server 10.10 on a machine on my LAN and installed OpenSSH. My home directory is /home/jonas and I created a directory ~/code/ to contain my projects. I can log in to the Ubuntu Server from Windows 7 with Putty.

I installed Git on the server with sudo apt-get install git

Adding a remote repository

Now I want to add my Git repository on my Desktop to the Server. I tried to follow the instructions from Pragmatic Version Control Using Git.

From my Desktop I run these commands:

git remote add origin jonas@
git push origin master

But I got this error message:

fatal: 'jonas@' does not appear to be
 a git repository
fatal: The remote end hung up unexpectedly

What is the problem? How do I create the remote repository?

As PerfectlyNormal suggested, I added a : in the address. Now it worked better, and I had to type my password to the server, but then I got a similar error message:

fatal: '/home/jonas/code/myproject.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly

Do I have to initialize a Git repository on the server before I can git push to it?

Did you setup the repository on the remote server? You need to run

mkdir -p /home/jonas/code/myproject.git
cd /home/jonas/code/myproject.git
git init --bare

on the server in order to set it up. I recommend taking a look at how to setup a git server in the free ProGit book.

How to Add a New Remote to your Git Repo, How do I add a file to a Git repository? Connecting your Local Repo. to Git Remote Server Ubuntu Create a User in remote server and assign permission for ssh access using ssh-keygen in your local server and paste, its .pub file to ssh of the remote server.

git remote add origin jonas@

When using SSH, remote repository addresses can be expressed in two ways. One using absolute paths and one using relative paths from the users home directory. You've mixed them up.

The corrected command would be one of the following.

git remote add origin jonas@
git remote add origin ssh://jonas@

We also assume you're running a standard Linux distribution like Ubuntu. Note that someone must shell onto the machine and create a bare repository every git remote add origin git@gitserver:/srv/git/project.git $ git push origin master. But here are a few commands that might be helpful as you use your new private git server. To clone a new repo you initialized on your private git server. $ git clone git@<IPADDRESS>:<repo-name> ~/git/. To add your new private git server to an existing repo. $ git remote add origin git@<IPADDRESS>:<repo-name>.git.

First thing I notice is that you're missing a ':'. Should be git remote add origin jonas@

Things to do on remote Server. Go to location : cd ~/srv/git srv in your root directory. Make a folder : mkdir your_file_name followed by cd inside your file inside your git folder. initialize git there : git init --bare Done. To do this login to your account on Then click on the "plus(+)" symbol at the top right corner of the page and select "create new repository". Fill the details as shown in the image below and click on "create repository" button.

I normally create a bare repository locally and then scp that repository to the server when I'm setting up a remote repository.

For example,

cd c:\gits
git clone --bare c:\path\to\local\repository\some_project

which creates some_project.git.


scp -r some_project.git login@some.server:/path/to/remote/gits/.

enter your password or maybe you already have public/private key access working.

To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. What I will do is guide you through the steps of setting up a Git repository on your VPS and giving you and your team access to that repository over SSH. You have to be familiar with the Git command-line client, so don’t come back and comment if you can’t get it right using TortoiseGit or whatsoever.

you need a colon:

git remote add origin jonas@

should be:

git remote add origin jonas@

The git remote add command takes two arguments: A unique remote name, for example, “my_awesome_new_remote_repo”; A remote URL, which you can find on  One is running a bare, basic Git server and and the second one is via a GUI tool called GitLab. For this tutorial I used a fully patched Ubuntu 14.04 LTS server running on a VPS. Install Git on your server. In this tutorial we are considering a use-case where we have a remote server and a local server and we will work between these machines.

The Git server can be set up on any remote Linux machine or even on your local system. You're now ready to create your first Git repository. As long as the pull is successful, the remote server will sync up to your repository and all changes will go live. Instillation. Add this file to your git ignore; Configure the file to your liking; Enable SSH on your remote server; SSH to your server and set up git and your repo (may require root access) Clone your repo to your remote server

Jack Wallen shows you how to create an HTTP Git Server in less than 10 Git repository vulnerability leads to remote code execution attacks  git init git remote add and directories to the repository: git add . Install HTTP Git Server with Nginx on Ubuntu 18.04 LTS as ready to use virtual machine

Check out my previous post “First steps to securing Ubuntu Server 18.04 on Digital Ocean” if you git remote add origin git@<IPADDRESS>:<repo-name>.​git. Then, John, Josie, or Jessica can push the first version of their project into that repository by adding it as a remote and pushing up a branch. Note that someone must shell onto the machine and create a bare repository every time you want to add a project. Let’s use gitserver as the hostname of the server on which you’ve set up your git user and repository.

  • Thanks, this seem to work. But how can I checkout the project on the server? If I do git status then I get a message that I must be on a "work tree"
  • You can't. A remote repository must be a bare repository, which cannot be used for working on. See this answer for more information. If you want to be able to work on the repo on the server as well, you need to checkout the repository in another directory on the server as well and use it just as if you were on a different computer (i.e. you must pull and push as usual).
  • @andrew-marshall Is that true? Couldn't he use a non-bare repo on the server and then push to working-dir/.git? Clearly, this is not a typical setup but isn't it possible?
  • It's possible but will lead to unexpected results if you push to a branch on a remote repository that is checked-out on the remote machine. In fact, I don't think recent versions of git (1.7+ perhaps?) will even allow you to do so.
  • Pushing to the checked out branch in a non-bare repo is disabled by default. You can change the setting in every non-bare repo you create but its the default for a very good reason and unless you know exactly what you are doing you likely shouldn't even be attempting it.
  • On a Mac, the format jonas@ worked!
  • This creates a new repository on a remote server, without being 'there'. Works fine for me.