Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 3.65 KB

adding-a-file-to-a-repository.md

File metadata and controls

75 lines (59 loc) · 3.65 KB
title intro redirect_from versions topics shortTitle
Adding a file to a repository
You can upload and commit an existing file to a repository on {% data variables.product.product_name %} or by using the command line.
/articles/adding-a-file-to-a-repository
/github/managing-files-in-a-repository/adding-a-file-to-a-repository
/articles/adding-a-file-to-a-repository-from-the-command-line
/articles/adding-a-file-to-a-repository-using-the-command-line
/github/managing-files-in-a-repository/adding-a-file-to-a-repository-using-the-command-line
/github/managing-files-in-a-repository/managing-files-on-github/adding-a-file-to-a-repository
/github/managing-files-in-a-repository/managing-files-using-the-command-line/adding-a-file-to-a-repository-using-the-command-line
fpt ghes ghae ghec
*
*
*
*
Repositories
Add a file

Adding a file to a repository on {% data variables.product.product_name %}

Files that you add to a repository via a browser are limited to {% data variables.large_files.max_github_browser_size %} per file. You can add larger files, up to {% data variables.large_files.max_github_size %} each, via the command line. For more information, see "Adding a file to a repository using the command line."

{% tip %}

Tips:

  • You can upload multiple files to {% data variables.product.product_name %} at the same time.
  • {% data reusables.repositories.protected-branches-block-web-edits-uploads %}

{% endtip %}

{% data reusables.repositories.navigate-to-repo %} 2. Above the list of files, using the Add file drop-down, click Upload files. "Upload files" in the "Add file" dropdown 3. Drag and drop the file or folder you'd like to upload to your repository onto the file tree. Drag and drop area {% data reusables.files.write_commit_message %} {% data reusables.files.choose_commit_branch %} 6. Click Commit changes. Commit changes button

Adding a file to a repository using the command line

You can upload an existing file to a repository on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.product.product_location %}{% endif %} using the command line.

{% tip %}

Tip: You can also add an existing file to a repository from the {% data variables.product.product_name %} website.

{% endtip %}

{% data reusables.command_line.manipulating_file_prereqs %}

{% data reusables.repositories.sensitive-info-warning %}

  1. On your computer, move the file you'd like to upload to {% data variables.product.product_name %} into the local directory that was created when you cloned the repository. {% data reusables.command_line.open_the_multi_os_terminal %} {% data reusables.command_line.switching_directories_procedural %} {% data reusables.git.stage_for_commit %}
$ git add .
# Adds the file to your local repository and stages it for commit. {% data reusables.git.unstage-codeblock %}

{% data reusables.git.commit-file %}

$ git commit -m "Add existing file"
# Commits the tracked changes and prepares them to be pushed to a remote repository. {% data reusables.git.reset-head-to-previous-commit-codeblock %}

{% data reusables.git.git-push %}

Further reading