How do I use my Git repository?

Before you can commit files to ProjectHut, you must first create a Git repository to store the files. The following instructions assume you have already created your origin repository using the ProjectHut Control Panel.

From the Control Panel, you will be able to obtain the repository URL. For example, the URL for the myproject repository in the mycompany account is of the form:

Cloning the repository

In order to use a Git repository, it is first necessary to clone it to create a local copy. For example, using the Git command-line tools for the ProjectHut account mycompany and a repository called myproject, you would type the following commands:

$ git clone
Cloning into 'myproject'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done

Unless you have enabled public (unauthenticated) access for your repository, you will be prompted to enter the username and password of one of the Users specified in the Git permissions screen for this repository.

Tip: Once you have entered a valid username/password combination the Git command will remember the credentials for the next Git operation. Alternatively, you can specify the username and password in the URL itself. For example:

$ git clone

By creating a clone of a repository in this way you will automatically set the remote ‘origin’ repository to point at the original ProjectHut repository.

Commit files to your local repository

To make some changes and store some files in the repository, you need to commit them locally first. To do this, you need to ‘add’ the files you wish to store, then ‘commit’ them. For example, to add an empty README file to the repository, you would use the following commands:

$ cd myproject/
$ touch README
$ git add README
$ git commit -m "First commit"
[master (root-commit) 646d594] First commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README

The files are now stored in your local repository, but not yet in the remote ProjectHut repository.

Upload local changes to ProjectHut using ‘push’

To upload the local changes to ProjectHut, you need to ‘push’ them to the origin repository. For example:

$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 211 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
 * [new branch]      master -> master

This command tells Git to push local changes to the ‘master’ branch of the ‘origin’ repository, which in this case, is the repository hosted at ProjectHut.

Download and merge remote changes using ‘pull’

One you have pushed your local changes to the ProjectHut repository, other developers can download these changes and commit their own changes.

To download the changes at the ProjectHut repository and merge them into your own local repository, you can use the ‘pull’ command:

$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
   646d594..76fe983  master     -> origin/master
Updating 646d594..76fe983
 some_other_file | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 some_other_file

Note: It is usually first necessary to ‘pull’ any remote changes in the origin repository before it is possible to ‘push’ your local changes. Failure to ‘pull’ the remote changes first will result in an error, similar to the following:

$ git push origin master
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to ''
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge the remote changes (e.g.,
hint: 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

This error message tells you that the remote repository contains changes that have not yet been replicated locally. In this case, running the Git commands ‘pull’ and ‘rebase’ prior to the ‘push’ would resolve the error.

Also, in the case when there are already other local commits, a ‘fast-forward’ pull may not be possible. In this case, you may be required to merge the changes from the pull and resolve any conflicts as a separate commit to your local repository first, prior to pushing your local changes.


Leave a Reply