
Source code: https://git.io/fjBs8
When you work on a project, it is very likely that you will want to store the files generated in your Cloud9 development environment to some common repository outside this EC2 VM. One reason is so that you don’t lose your code if anything happens to this VM on AWS
Otherwise also, there might be many developers working on the same project and each of them may want to add or make changes to files and store them outside of their environment into some common place.
This is where GitHub.com comes in. It is where most of today’s open-source projects are developed.
In this blogpost, we will look at integrating your development environment in order to get the ability to sync your work to a remote location where it is integrated with work done by others
Step-1: Sign-in to your GitHub account
Step-2: Create a new repository on GitHub
2.1: Click on New repository option in top right-hand corner dropdown menu on GitHub website

2.2: Enter Name of repository, Select it as Public and Don’t forget to click check box “Initialize this repository with a README” as shown above and then click Create Repository button

2.3: You should see landing page showing the repository created along with a README.md file
Step-3: Update/Upgrade your Cloud9 environment
3.1: Open your Cloud9 IDE, right-click on root folder (C9.NodeJS in my case) and select option Open Terminal Here from the menu

3.2: In the open terminal window, type the following commands
- sudo apt update
- sudo apt upgrade
- sudo apt autoremove
if at anytime during executing above command, if you get a prompt asking Do you want to continue (Y/n), please type Y and Enter.
This will help bring your EC2 instance hosting your Cloud9 IDE and running on Ubuntu OS to latest patches.
Step-4: Install Git in your Cloud9 environment
4.1: Right-click on root folder and create a new folder under it called “repository”

4.2: On your terminal windows, navigate to this repository folder
cd repository
4.3: Check if git is installed

4.4 Set your Git UserName and EmailAddress by running below commands

If there is nothing shown on terminal and cursor moves to next line, it means, command executed successfully.
Step-5: Clone remote GitHub repository in your environment
5.1: Visit your GitHub repository page, click small downward arrow on right side of green button named “Clone or download”.

5.2: Click “User HTTPS” link to get URL of your git repository in https format

Copy this URL into clipboard
5.3: Now go back to terminal window in your Cloud9 IDE and run following command
git clone https://github.com/AshKamdar/AdventuresInCloud.git
Make sure to put Your git URL which you copied in above command
5.4: Congratulations. You have successfully cloned your remote GitHub repository into your Cloud9 environment.

Also, if you refresh your repository folder, you can see it now has contents that were present in our GitHub repository.
Step-6: Adding files to local repository and pushing them to GitHub
6.1: Right-click on AdventuresInCloud folder and click New File and create a file named testing.txt

6.2: Open the file by double-clicking it and scribble some text in it

6.3: Run the following three commands. First to clear previous contents, second to move into repository folder and third to see whether git recognized our newly created file “testing.txt”
clear
cd AdventuresInCloud
git status

As you can see, git has identified creation of new file locally.
6.4: Add file testing.txt to git staging area by running following command

6.5: Commit staged files to local git repository


This means the file is now part of local git repository and it has started tracking (version controlling) it.
6.6: Now we want to push this file to GitHub, so it is no longer just in this machine but is added to our common repository folder on GitHub, where presumably other developers are also adding their files from their own development environments
git push
You will be prompted to enter your username/password and after that, Git will work to sync contents of your local git repo with the one on GitHub website

6.7: You can verify that the file is pushed by visiting the GitHub website


Step-7: Pull newly added file(s) from GitHub to local environment
You can do this exercise as practice.
7.1 Add a new file in GitHub website in our repository “AdventuresInCloud”
7.2 Come back to our Cloud9 environment and execute the command
git pull


You will see that the file is being Pulled from GitHub to your local environment
Conclusion
So this way, we can integrate our Cloud9 environment with GitHub to store all our source code in a global repository.
Happy Clouding!
Hi, I just looked at your website and really impressed by it’s design and content. You are doing a great job by providing such information to the audience. Thank you so much.
LikeLiked by 1 person
Thanks for your kind words Rosalva.
LikeLiked by 1 person