Using GIT in CloudForge via command line

Supported GIT Client

Download GIT here. (Only clients using GIT 1.7.X and above are supported)

What protocols does CloudForge support for GIT?

You can either use HTTPS or SSH.

  • HTTPS: Uses your CloudForge username and password to authenticate
  • SSH: Uses a private and public SSH key pair to authenticate.

Your choice. Using HTTPS is arguably easier, since you only need your username and password. But most likely it will require you to enter your password every time.

While SSH takes a bit to setup - you need to create an SSH key pair, and upload the Public key to CloudForge - in the long run is more convenient. More details on both below. Make sure to get the respective GIT URL from your project page:

Screen_Shot_2012-11-01_at_4.39.20_PM.png

 

Using GIT with HTTPS

Your GIT HTTPS URL will look like this: https://USER@ORG.git.cloudforge.com/PROJECT.git

Here is an example: 

git clone https://user@org.git.cloudforge.com/project.git

You will be prompted to enter your password
You can now cd into the product directory from the clone

touch test.txt
git add .
git commit -a -m "test"
git push origin master

After you've that once, you can merely "git push" as normal. The "origin master" is only required the first time.

Using GIT with SSH

Your GIT SSH URL will look like: ssh://git_ORG@ORG.git.cloudforge.com/PROJECT.git

Follow this steps:

  • Upload your SSH public key first to CloudForge:

     Screen_Shot_2012-11-01_at_4.51.17_PM.png
    (Also available from "My Settings" in your CloudForge account)
     
  • If you don't have a pair of SSH keys, run in the command line: ssh-keygen
  • Set your .gitconfig
    • $ git config --global user.name "Johnny Beans"
    • $ git config --global user.email "awesome_dev@mycompany.com"
    • Make sure your email is the same as the one you use in CloudForge.

(ORG is your CloudForge domain, and PROJECT is the name of your project - Access URLs are available in the Project detail page in your CloudForge Dashboard)

  1. git clone ssh://git_ORG@ORG.git.cloudforge.com/PROJECT.git
  2. You will NOT be prompted to enter your password - Assuming you uploaded your public key, and your private key is in ~/.ssh - you should be good.
  3. You can now cd into the product directory from the clone
  4. touch test.txt
  5. git add .
  6. git commit -a -m "test"
  7. git push origin master

After you've done #7 once, you can merely "git push" as normal. The "origin master" is only required the first time.

Common Errors

  1. While pushing to CloudForge Git repository, you get error: Cannot access URL https://user@org.git.cloudforge.com/project.git, return code 22 error: failed to push some refs to 'https://user@copello.git.cloudforge.com/project.git'.  This is most likely because you are using an older Git client.  Make sure your git client is 1.7.x and above.
  2. While pushing to CloudForge Git remote repository, you get error: RPC failed; result=22, HTTP code = 401.  This means that you don't have Git Developer (R/W) permission to the repository.
  3. While executing a git clone command, you get error: The requested URL returned error: 401 while accessing https://user@org.git.cloudforge.com/project.git/info/refs.  This means that you don't have access at all to the Git repository.

Anytime you see a http error code 401, it means that you need to configure CloudForge security properly in order to gain access to CloudForge Git repository.

 

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.