This article covers managing source code with Sourcetree, a Git GUI client, and AWS CodeCommit, Amazon’s repository service.

The short answer: since 25 July 2024, AWS accounts without an existing CodeCommit repository can no longer create one. If you are setting up source control from scratch today, you will be choosing GitHub or GitLab instead.

Accounts already using CodeCommit can carry on as before. So this article starts with the current availability, then covers the Sourcetree setup for existing users and the alternatives for everyone else.

AWS CodeCommit closed to new customers on 25 July 2024

The short answer: AWS stopped onboarding new CodeCommit customers on that date. Only accounts that had already created a repository can create more.

Account state What you can do
Created a repository before 25 July 2024 Use existing repositories and create new ones
Never used CodeCommit, or a newly created AWS account Cannot create repositories

AWS says it will continue investing in security, availability and performance for existing users, but has no plans to add new features. No end-of-service date has been announced.

If you try to create a repository from the console on an account that never used it, the attempt fails in a way that looks like a permissions error. It is easy to start debugging IAM, but the cause is not permissions; the account is simply outside the eligible group.

 

What should you use instead?

The short answer: GitHub for personal projects and most teams, Amazon CodeCatalyst if you want to stay inside AWS.

Service Good for Notes
GitHub Personal work, open source, general team development Private repositories available on the free tier
GitLab Keeping CI/CD in one place Self-hosted edition available
Amazon CodeCatalyst Integrating with other AWS services The replacement AWS itself points to

Sourcetree works as a Git client against any of them. Only the remote changes; committing and pushing are identical. For the GitHub side specifically, cloning a private GitHub repository in Sourcetree with a token covers the authentication you will need.

 

Installing and setting up Sourcetree

The short answer: Sourcetree is a free Git and Mercurial GUI client from Atlassian, available for Windows and macOS.

Download the installer from the Sourcetree site and run it. You will be asked to sign in with an Atlassian account on first launch.

After installing, set the name and email address used for commits. Without these you cannot commit at all.

  • macOS: Sourcetree menu, then Settings, then General
  • Windows: Tools, then Options, then General

 

The value of Sourcetree is being able to assemble a commit while looking at the diff, rather than staging blind on the command line.

 

Creating credentials for CodeCommit

The short answer: to connect over HTTPS you generate “HTTPS Git credentials for AWS CodeCommit” on an IAM user. Your AWS console password will not work.

  1. Open IAM in the AWS Management Console
  2. Select the IAM user you will connect as and open the Security credentials tab
  3. Under HTTPS Git credentials for AWS CodeCommit, choose Generate credentials
  4. Record the username and password shown; the password is displayed only once

 

That IAM user needs a policy such as AWSCodeCommitPowerUser. Without it, authentication succeeds but the repository list comes back empty.

The generated password cannot be redisplayed. If you lose it, delete the credentials and generate a new pair.

 

Cloning a repository into Sourcetree

The short answer: paste the HTTPS URL from the CodeCommit console into Sourcetree’s Clone dialog and sign in with the HTTPS Git credentials.

The URL takes the form https://git-codecommit.REGION.amazonaws.com/v1/repos/REPOSITORY. Open the repository in the CodeCommit console and copy it from Clone URL.

  1. In Sourcetree choose New, then Clone from URL
  2. Paste the CodeCommit HTTPS URL as the source
  3. Choose a local directory
  4. When prompted, enter the HTTPS Git credentials

 

If Sourcetree reports that this is not a valid source path or URL as soon as you paste, check the spelling of the region and the repository name.

 

Committing and pushing

The short answer: stage the changed files, write a message, commit, then Push to send it to the remote.

The Sourcetree window splits into Unstaged files on top and Staged files below.

  • Stage: tick the checkbox beside a filename, or select it and press Stage Selected
  • Commit: write a message in the field at the bottom and press Commit
  • Publish: press Push in the toolbar and pick the branch
  • Fetch others’ work: press Pull

 

A commit only records to your local repository. Nothing reaches CodeCommit until you push. This applies to every Git GUI client, not just Sourcetree.

 

Migrating off CodeCommit

The short answer: make a mirror clone and push it to the new host; history and branches come across intact.

git clone --mirror https://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/REPOSITORY
cd REPOSITORY.git
git push --mirror https://github.com/USER/REPOSITORY.git

 

--mirror includes every branch and tag. Afterwards run git remote set-url origin NEW_URL in your working clones to point them at the new host.

Before migrating, check anything that referenced the old repository, such as build configuration and webhook targets. If you authenticate to servers with SSH keys and need to move between key formats, converting pem and ppk on a Mac with PuTTYgen covers that.

ABOUT ME
りん
On this blog, I mainly share information about web development and programming, along with my daily thoughts and what I’ve learned. I aim to create a blog that lets readers enjoy both technology and everyday life, so I also include topics about daily experiences, books, and gourmet. I’d be delighted if you could drop by casually and find something useful or enjoyable here.