Web and App Development Tutorials

Git Repositories - Setup both GitHub and AWS CodeCommit Together

Step 01 Clone Your GitHub Repository

Clone Your GitHub Repository

First clone your desired GitHub remote repository to your local machine. For testing you can use our GitHub tutorial_example or replace it with your own.

Step 02 Go Into Your Repository Folder

Go Into Your Repository Folder

Go into your repository folder you just cloned by running the cd command. If you're using the cloned tutorial_example repository from above use the following command or feel free to use your own.

Step 03 List Your Remote Repositories

List Your Remote Repositories

We will use this command quite a few times in this tutorial to inspect the changes as we go along. This is a way to list your remote repositories connected to your local repository copy. The command should show something similar to the example repositories below.

origin [email protected]:phcdevworks/tutorial_example.git (fetch) 

origin [email protected]:phcdevworks/tutorial_example.git (push)

Step 04 Rename the GitHub Repo from the Default

Rename the GitHub Repo from the Default

Rename repo for the default Origin to Github to be more organized.

Step 05 Clone Your CodeCommit Repository

Clone Your CodeCommit Repository

Clone your CodeCommit private repo.

Step 06 List Your Remote Repositories

List Your Remote Repositories

List your remote repositories again to make sure the previous step was successfully. You should new see your new remote CodeCommit repository.

github [email protected]:phcdevworks/tutorial_example.git (fetch) 

github [email protected]:phcdevworks/tutorial_example.git (push)

codecommit <codecommit address> (fetch)

codecommit <codecommit address> (push)

Step 07 Add a New Remote All

Add a New Remote All

The next 3 steps we'll setup the all command for both GitHub and CodeCommit repos.

Step 08 Add a New Remote All for GitHub Repo

Add a New Remote All for GitHub Repo

We will add a new remote all command for your github account.

Step 09 Add a New Remote All for CodeCommit Repo

Add a New Remote All for CodeCommit Repo

We will add a new remote all command for your codecommit account.

Step 10 List Your Remote Repositories

List Your Remote Repositories

List your remote repositories to make sure the previous step was successful. You should new see the all pushes properly setup.

all [email protected]:phcdevworks/tutorial_example.git (fetch)

all [email protected]:phcdevworks/tutorial_example.git (push)

all <codecommit address> (push)

 

github [email protected]:phcdevworks/tutorial_example.git (fetch) 

github [email protected]:phcdevworks/tutorial_example.git (push)

codecommit <codecommit address> (fetch)

codecommit <codecommit address> (push)

Step 11 Set the Upstream to All

Set the Upstream to All

Setup the default upstream to all. Going forward the regular push command will push commits to both remote repositories.