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:
- Created a repository on GitHub Enterprise, or are a collaborator on someone else's repository.
- Cloned the repository locally on your computer
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."
- 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.
Open Terminal (for Mac and Linux users) or the command prompt (for Windows users).
Change the current working directory to your local repository.
-
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'.
-
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.
-
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