You can upload an existing file to a GitHub Enterprise repository using the command line.

While you can add a new file to a repository from the GitHub Enterprise website, you may have an existing file you'd like to include in your repository.

This procedure assumes you've already:

Warning: Never git add, commit, or push sensitive information to a remote repository. Sensitive information can include, but is not limited to:

  • Passwords
  • SSH keys
  • AWS access keys
  • API keys
  • Credit card numbers
  • PIN numbers

For more information, see "Remove sensitive data."

  1. On your computer, move the file you'd like to upload to GitHub Enterprise into the local directory that was created when you cloned the repository.
  2. Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).

  3. Change the current working directory to your local repository.

  4. Stage the file for the first commit to your repository.

    git add .
    # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
    
  5. Commit the files that you've staged in your local repository.

    git commit -m "First commit"
    # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
    
  6. Push the changes in your local repository to your GitHub Enterprise instance.

    git push origin master
    # Pushes the changes in your local repository up to the remote repository you specified as the origin
    

Further reading