Instructions to port/push Cloud9 Workspace to GitHub


#1

I have a GitHub account. I have not been able to port/push to GitHub. I need fairly specific instructions.

Thanking in advance.


#2

Hi @emcgurty Do you have a remote repository on GitHub to push to?


#3

Yes. My github account is username emcgurty. With Cloud9 I just don’t
where how/where to start? Does Cloud9 have functionality to automatically
generate a new repository, or should I create a new gitHub repository and
then…

Thanks for your very rapid reply…


#4

#5

Hi @emcgurty when I start a project I create a bare repository on GitHub with a .gitignore, README.md and LICENSE file. Then I clone it to Cloud 9 using the workspace terminal with the command:

>git clone https://github.com/user/repo-name e.g. git clone https://github.com/emcgurty/echomarket.git. Repo’s URL obtainable from the repository’s green ‘Clone or download’ button.

The Git docs are a good resource for getting to grips with the terminal commands, otherwise nodeschool have a workshop called git-it that I found very useful.


#6

Didn’t work. Have clone
https://github.com/emcgurty/Echomarket_ROR4_Cloud9.git. Went to workspace,
opened new terminal and typed

git clone https://github.com/emcgurty/Echomarket_ROR4_Cloud9.git

Nothing happened


#7

Cloning into ‘Echomarket_ROR4_Cloud9’…
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done


#8

And just for the record, I would understand if I replied to you within the
Cloud9 Community my responses would be public. Very surprised to see that
my responses from my gmail account are public.


#9

What type of Cloud 9 workspace are using? I’ve just cloned your repo using a blank workspace template.


#10

Ruby On Rails, version 4


#11

Just received message:

Body is too short (minimum is 20 characters)
Body seems unclear, is it a complete sentence?

I do not understand type? The programming language I am using is Ruby on
Rail, version 4 with a mySQL database.


#12

Are you still working this? Just wondering.


#13

If you are trying to push existing code to a GitHub repository, first create a blank GitHub repository (no README or .gitignore). Then go to your workspace and do the following:

  • If the workspace doesn’t have git initialized (you can test this by running ls in the workspace folder, and if there’s a .git folder, then it’s initialized, so skip this step), run git init to initialize it.
  • Now, set up your GitHub repository as a “remote”:
    git remote add <remote name> git@github.com:emcgurty/Echomarket_ROR4_Cloud9.git. The remote name could be anything, like github, but the convention is to use origin as in git remote add origin git@github.com:emcgurty/Echomarket_ROR4_Cloud9.git.
  • Make sure to add the Cloud9 SSH public key to GitHub. To do this, go to https://c9.io/account/ssh, and copy the key (looks like ssh-rsa ...). Then, go to https://github.com/settings/keys, click “New SSH key”, use “Cloud9” as the name, and paste the public key in the box, and click “Add SSH key”.
  • In the Cloud9 terminal, you can now upload your code. Run git push <remote name> <branch name>, for instance git push origin master. Every few commits, you can run this to update GitHub with your changes. If you receive an error mentioning that you should run git pull first, that means that you have files in the remote repository. To fix this, you can run git pull, but if there are any common files (maybe there’s a README on GitHub and one locally, it will error out, so you may have to temporarily move your local file, and merge them after git pull, then commit and push with git push origin master.

#14

At SSH Keys, https://c9.io/account/ssh, there are two options:
Connect to your Server using SSH and Connect to your private git
repository. Which should I choose?


#15

Add just for the record, in this testing effort, I am now not able to push
to other unrelated GitHub repositories.


#16

In testing effort I have changed GitHub source multiple times, yet Cloud9
does not recognize new. How can I start from scratch in this effort?
Delete hidden.git?


#17

If you want to start again, just delete the .git directory in your workspace. Generally pushing to Github using https seems to work pretty well for me (my workplace, for some reason, blocks SSH traffic). I have done it by:

  • Initialize the workspace as a git repository by typing git init in the bash terminal tab (this will create the .git directory in your workspace
  • Add your project files to the local repository by using git add . (not the space before the period/dot).
  • Commit your files to the local respository using git commit -m “your commit message
  • Add your Github repository as a remote using
    git remote add origin https://yourusername@github.com/yourusername/yourproject,
    where origin is the name you give your github repository (one project can have several remote repositories)
  • Push your local repository (in your workspace) to Github using git push origin master,
    where master is the branch you want to push to your Github repository.
  • It will ask you for your Github password and push to the Github repository.

Good Luck, let us know how you go.


#18

Dear Johannesmu,

First of alI, I am no stranger to version control, beginning in 1992. I
have successfully utilized gitHub over the past five years with thousands
of push/commit. I have pursued this effort here ad nauseam. Tried git
init many times, used git remote rm to clear remotes, checked with git
remote -v. I did try to delete my hidden directory .git, but permission
was denied. Also was worried the ‘File History’ was related to .git
content. The success that I have had is that the Ruby on Rails folder /app
is locked in Github, I see a disabled folder icon.

I think that Cloud9 is totally amazing, but this process in porting/pushing
to GitHub has been too difficult.

BTW: My github repo: Echomarket_Java_To_ROR4 I created in about five minutes from Workspace Download, offered as a demonstration of my understanding of GitHub


#19

Happy ending!

Right-clicked in right Navigate Panel and displayed Hidden Files.
Deleted all .git directories
Created a new GitHub repository: echomarket_cloud9, without a README file and without SSH specific to Cloud9
Opened new terminal in Cloud9 and entered the following commands

git init
git config --global user.name "My Name"
git config --global user.email "My Email"
git remote add origin https://github.com/myusername/echomarket_cloud9.git
git add .
git commit -m "First Commit"
git push origin master

Was prompted for my github username and password
Worked like a charm

Next commit I should be able to just enter

git add .
git commit -m "First Commit"
git push origin master