AWS CodeCommit is no longer available to new customers. Existing customers of
AWS CodeCommit can continue to use the service as normal.
Learn more"
Basic Git commands
You can use Git to work with a local repo and the CodeCommit repository to which you've connected the local repo.
The following are some basic examples of frequently used Git commands.
For more options, see your Git documentation.
Configuration variables
Lists all configuration variables. |
|
Lists only local configuration variables. |
|
Lists only system configuration variables. |
|
Lists only global configuration variables. |
|
Sets a configuration variable in the specified configuration file. |
|
Sets the default branch name to main for all local repositories when an initial commit is made to a repository that does not yet have a default branch | git config --global init.defaultBranch main |
Edits a configuration file directly. Can also be used to discover the location
of a specific configuration file. To exit edit mode, typically you type
|
|
Remote repositories
Initializes a local repo in preparation for connecting it to an CodeCommit repository. |
|
Can be used to set up a connection between a local repo and a remote repository (such as a CodeCommit repository) using the specified nickname the local repo has for the CodeCommit repository and the specified URL to the CodeCommit repository. |
|
Creates a local repo by making a copy of a CodeCommit repository at the specified URL, in the specified subfolder of the current folder on the local machine. This command also creates a remote tracking branch for each branch in the cloned CodeCommit repository and creates and checks out an initial branch that is forked from the current default branch in the cloned CodeCommit repository. |
|
Shows the nickname the local repo uses for the CodeCommit repository. |
|
Shows the nickname and the URL the local repo uses for fetches and pushes to the CodeCommit repository. |
|
Pushes finalized commits from the local repo to the CodeCommit repository, using the specified nickname the local repo has for the CodeCommit repository and the specified branch. Also sets up upstream tracking information for the local repo during the push. |
|
Pushes finalized commits from the local repo to the CodeCommit repository after upstream tracking information is set. |
|
Pulls finalized commits to the local repo from the CodeCommit repository, using the specified nickname the local repo has for the CodeCommit repository and the specified branch |
|
Pulls finalized commits to the local repo from the CodeCommit repository after upstream tracking information is set. |
|
Disconnects the local repo from the CodeCommit repository, using the specified nickname the local repo has for the CodeCommit repository. |
|
Commits
Shows what has or hasn't been added to the pending commit in the local repo. |
|
Shows what has or hasn't been added to the pending commit in the local repo in a concise format. ( |
|
Shows changes between the pending commit and the latest commit in the local repo. |
|
Adds specific files to the pending commit in the local repo. |
|
Adds all new, modified, and deleted files to the pending commit in the local repo. |
|
Begins finalizing the pending commit in the local repo, which displays an editor to provide a commit message. After the message is entered, the pending commit is finalized. |
|
Finalizes the pending commit in the local repo, including specifying a commit message at the same time. |
|
Lists recent commits in the local repo. |
|
Lists recent commits in the local repo in a graph format. |
|
Lists recent commits in the local repo in a predefined condensed format. |
|
Lists recent commits in the local repo in a predefined condensed format, with a graph. |
|
Lists recent commits in the local repo in a custom format, with a graph. (For more options, see Git Basics
- Viewing the Commit History |
|
Branches
Lists all branches in the local repo with an asterisk
( |
|
Pulls information about all existing branches in the CodeCommit repository to the local repo. |
|
Lists all branches in the local repo and remote tracking branches in the local repo. |
|
Lists only remote tracking branches in the local repo. |
|
Creates a new branch in the local repo using the specified branch name. |
|
Switches to another branch in the local repo using the specified branch name. |
|
Creates a new branch in the local repo using the specified branch name, and then switches to it. |
|
Pushes a new branch from the local repo to the CodeCommit repository using the specified nickname the local repo has for the CodeCommit repository and the specified branch name. Also sets up upstream tracking information for the branch in the local repo during the push. |
|
Creates a new branch in the local repo using the specified branch name. Then connects the new branch in the local repo to an existing branch in the CodeCommit repository, using the specified nickname the local repo has for the CodeCommit repository and the specified branch name. |
|
Merges changes from another branch in the local repo to the current branch in the local repo. |
|
Deletes a branch in the local repo unless it contains work that has not been merged. |
|
Deletes a branch in the CodeCommit repository using the specified nickname the
local repo has for the CodeCommit repository and the specified branch name. (Note
the use of the colon ( |
|
Tags
Lists all tags in the local repo. |
|
Pulls all tags from the CodeCommit repository to the local repo. |
|
Shows information about a specific tag in the local repo. |
|
Creates a "lightweight" tag in the local repo. |
|
Pushes a specific tag from the local repo to the CodeCommit repository using the specified nickname the local repo has for the CodeCommit repository and the specified tag name. |
|
Pushes all tags from the local repo to the CodeCommit repository using the specified nickname the local repo has for the CodeCommit repository. |
|
Deletes a tag in the local repo. |
|
Deletes a tag in the CodeCommit repository using the specified nickname the
local repo has for the CodeCommit repository and the specified tag name. (Note the
use of the colon ( |
|