Pushing to a repository

Last updated by Adam West on August 28, 2019 16:58

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.

Pushing your Git 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 documentation.

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 a new Git 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 Git 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

Pushing your Mercurial repository

Firstly you will need to make sure you have Mercurial 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 documentation.

Install and configure Mercurial on your computer

Once you have Mercurial installed you will need to start by running the following commands in your command line / terminal to tell codebase who you are (replacing the example user information with your own details)

1. Edit ~/.hgrc to include your name and e-mail address:

$ nano ~/.hgrc

2. Paste the following into that file:

[ui] username = Adam West <support@codebasehq.com>

Type control+x, followed by y and the enter key to save the changes.

Create and push a new Mercurial repository 

1. Enter the directory which you wish to import to Codebase

$ cd path/to/local/folder

2. Initialise the folder as a Mercurial repository

$ hg init

3. Add all files and commit for the first time

$ hg add
$ hg commit -m "Initial commit"

4. Send commits to Codebase

$ hg push ssh://hg@codebasehq.com/my-account/my-project/my-repository.hg

Create and push an existing Mercurial repository 

If you already have a local Mercurial repository setup, all you will need to do is navigate to your repository directory in your terminal, then run the hg push command to push it to Codebase.

$ hg push ssh://hg@codebasehq.com/my-account/my-project/my-repository.hg