Pushing to a repository

Last updated by Adam West on November 29, 2017 10:40

If you have just created a new repository or navigated to an empty repository you will be given directions (below) on how to push your project to your codebase repository.

Firstly you will need to make sure you have Git installed on your system and have your SSH Public Key linked to codebase, if you do not have either of these then please look at the Getting Started Documents.

Install and configure Git on your computer

Once you have git installed you will need to start by running the following commands in your command line / terminal to tell codebase who you are (replacing 'username' and 'email' with your user information)

$ git config --global user.name "username" 
$ git config --global user.email "email"

To Create and push an existing repository

Enter the directory on your local machine that you want to push to codebase. use the following command (replacing 'path/to/local/folder' with your file path)

$ cd path/to/local/folder

Then you will need to initialise Git in this directory by running the following command.

$ git init  
Initialized empty Git repository in path/to/local/folder

The next thing to do is to tell Git that you want to add all the files in this directory to a version and commit them, you do that with the following commands.

$ git add . 
$ git commit -m 'initial commit'  
[master (root-commit) 5cc0002] 
initial commit 0 files changed, 0 insertions(+), 0 deletions(-) 
create mode 100644 README

Finally you will need to add a remote reference for the codebase repository that you have made and push all changes to the new reference ('origin').

$ git remote add origin git@codebasehq.com:yourcodebasedomain/yourproject/example.git 
$ git push origin master  
Counting objects: 3, done. 
Writing objects: 100% (3/3), 205 bytes, done. 
Total 3 (delta 0), reused 0 (delta 0) 
To git@codebasehq.com:example/example/example.git * [new branch]      
master -> master

Push an existing local repository

If you already have a local Git repository setup, all you will need to do is setup the remote reference for the new Codebase repository and push all branches to it, using the following commands.

$ git remote add origin git@codebasehq.com:yourcodebasedomain/yourproject/example.git 
$ git push origin --mirror  
Counting objects: 3, done. 
Writing objects: 100% (3/3), 205 bytes, done. 
Total 3 (delta 0), reused 0 (delta 0) 
To git@codebasehq.com:example/example/example.git * [new branch]      
master -> master * [new branch]      
devel -> devel