| 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 |
|
||||||||
| versions |
|
||||||||
| shortTitle | Add a file | ||||||||
| category |
|
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 %}
-
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.
-
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 %}
-
Click Propose changes.
You can upload an existing file to a repository on {% data variables.product.prodname_dotcom %} using the command line.
Tip
You can also add an existing file to a repository from the {% data variables.product.github %} website.
{% data reusables.command_line.manipulating_file_prereqs %}
{% data reusables.repositories.sensitive-info-warning %}
-
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 %}
- AUTOTITLE {% endif %}
