Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 4.83 KB

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

File metadata and controls

83 lines (60 loc) · 4.83 KB
title Adding a file to a repository
intro You can upload and commit an existing file to a repository on {% data variables.product.github %} or by using the command line.
redirect_from
/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
/github/managing-large-files/about-large-files-on-github
versions
fpt ghes ghec
*
*
*
shortTitle Add a file
category
Work with files

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

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. To add files larger than {% data variables.large_files.max_github_size %}, you must use {% data variables.large_files.product_name_long %}. For more information, see AUTOTITLE.

You can upload up to 100 files to {% data variables.product.github %} at the same time.

{% data reusables.repositories.protected-branches-block-web-edits-uploads %}

{% data reusables.repositories.rulesets-push-rules-general-info-for-related-articles %}

Your repository may be secured by push protection. With push protection, {% data variables.product.prodname_dotcom %} will block uploading a file to the repository if the file contains a supported secret, such as a token. You should remove the secret from the file before attempting to upload the file again. For more information, see AUTOTITLE and AUTOTITLE.

{% data reusables.secret-scanning.push-protection-web-UI-uploads-beta %}

Warning

Use Git to push files to your repository if you need to apply the logic in your .gitattributes file. For example, automatic conversion of line endings. Uploading a file through the {% data variables.product.github %} web interface will ignore .gitattributes.

{% data reusables.repositories.navigate-to-repo %}

  1. Above the list of files, select the Add file dropdown menu and click Upload files. Alternatively, you can drag and drop files into your browser.

    Screenshot of the main page of the repository. Above the list of a files, a button, labeled "Add file," is outlined in dark orange.

  2. To select the files you want to upload, drag and drop the file or folder, or click choose your files. {% data reusables.files.commit-message %} {% data reusables.files.choose_commit_branch %}

  3. Click Propose changes.

Adding a file to a repository using the command line

You can upload an existing file to a repository on {% data variables.product.prodname_dotcom %} using the command line.

{% 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.github %} 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 %}

{% ifversion fpt or ghec %}

Further reading