How to add existing local git repository to remote server

Introduction

This post would demo how to add existing git repository to remote server.

Environments

  • Windows/Linux/Mac OS

The script

# Firstly , init the local repository as git repository
git init 
# add local repo to remote server
git remote add origin gituser@server_ip:/bswen.git
# push local branch master to remote origin
git push --set-upstream origin master
# check your settings is ok
git remote -v -a

git remote add introduction

As the git official site says:

Adds a remote named for the repository at . The command git fetch can then be used to create and update remote-tracking branches /.

git remote -v introduction

-v –verbose Be a little more verbose and show remote url after name. NOTE: This must be placed between remote and subcommand.

Summary

You should init the local git repo, and not forget to push the local master branch to remote server.

You can find detail documents about the git and remote here: