Adding files from your web browser
- Navigate to the GitHub repository you want to add files to.
- Click on the Add file dropdown button and select one of the options:
- Create new file
- Name your file in the box near the top left corner. Include the file extension (for example, about.md instead of about).
- Write your code and/or content in the <> Edit new file box.
- Upload files
- Click and drag the files from your file system into the indicated space. Or, click choose your files to navigate your file system instead of clicking and dragging.
- (Optional) Once you are finished creating or uploading your file, add a commit message in the first box underneath the Commit changes heading.
- If your commit message is longer than ~50 characters, consider writing a shorter description in the first box and adding extra details in the larger box below.
- Ensure that the Commit directly to the
master
branch option is selected.
- Note: If you have changed your default branch name from
master
to main
, the option would read Commit directly to the main
branch. For more information on this, you can click here.
- Click the green Commit changes button.
Adding files from the CLI
- Navigate to the GitHub repository you want to add files to.
- If you are adding a new file to this repository:
- Use the
touch
command to create a new file in your current directory. For example, if you want to make an HTML file called about, the command would be touch about.html
.
- If you are adding an existing file to this repository:
- Use the
mv
command to move an existing file from somewhere else on your computer to the current directory. The syntax for using mv
is mv currentFileLocation newFileLocation
.
- For example, if you wanted to move a file named
about.html
from one directory level up into your current directory, the command would be mv ../about.html .
.
- Stage your change with
git add <your filename here>
.
- Commit your change with
git ci
.
- Push your change to GitHub with
git push origin master
.
- Note: If you have changed your default branch name from
master
to main
, the command would instead be git push origin main
. For more information on this you can click here.
Adding files from the GitHub desktop app