Skip to main content
ドキュメントには� �繁に更新が� えられ、その都度公開されています。本ページの翻訳はま� 未完成な部分があることをご了承く� さい。最新の情� �については、英語のドキュメンテーションをご参照く� さい。本ページの翻訳に問題がある� �合はこちらまでご連絡く� さい。

このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2022-06-03. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの改善、新機能のためには、最新バージョンのGitHub Enterpriseにアップグレードしてく� さい。 アップグレードに関する支援については、GitHub Enterprise supportに連絡してく� さい。

Adding locally hosted code to GitHub

Learn how to add existing source code or repositories to GitHub Enterprise Server from the command line using GitHub CLI or Git Commands. Then, share your code and invite others to work with you.

About adding existing source code to GitHub Enterprise Server

If you have existing source code or repositories stored locally on your computer or private network you can add them to GitHub Enterprise Server by typing commands in a terminal. You can do this by typing Git commands directly, or by using GitHub CLI.

GitHub CLI は、コンピューターのコマンドラインから GitHub を使用するためのオープンソースツールです。 GitHub CLI can simplify the process of adding an existing project to GitHub Enterprise Server using the command line. To learn more about GitHub CLI, see "About GitHub CLI."

ヒント: ポイントアンドクリック型のユーザインターフェースに慣れている� �合は、プロジェクトを GitHub Desktopで追� してみてく� さい。 詳しい情� �については GitHub Desktopヘルプ 中のローカルコンピュータから GitHub Desktop へのリポジトリの追� を参照してく� さい。

警告: リモートリポジトリには、決してセンシティブな情� �をgit addcommitpushしないでく� さい。 センシティブな情� �には以下が含まれますが、以下に限定はされません。

詳細は「センシティブなデータをリポジトリから削除する」を参照してく� さい。

Adding a local repository to GitHub Enterprise Server with GitHub CLI

  1. In the command line, navigate to the root directory of your project.

  2. ローカルディレクトリを Git リポジトリとして初期化します。

    git init -b main
  3. Stage and commit all the files in your project

    git add . && git commit -m "initial commit"
  4. To create a repository for your project on GitHub, use the gh repo create subcommand. When prompted, select Push an existing local repository to GitHub and enter the desired name for your repository. If you want your project to belong to an organization instead of your user account, specify the organization name and project name with organization-name/project-name.

  5. Follow the interactive prompts. To add the remote and push the repository, confirm yes when asked to add the remote and push the commits to the current branch.

  6. Alternatively, to skip all the prompts, supply the path to the repository with the --source flag and pass a visibility flag (--public, --private, or --internal). For example, gh repo create --source=. --public. Specify a remote with the --remote flag. To push your commits, pass the --push flag. For more information about possible arguments, see the GitHub CLI manual.

Adding a local repository to GitHub Enterprise Server using Git

  1. GitHub Enterprise Serverインスタンス上で新しいリポジトリを作成します。 エラーを避けるため、新しいリポジトリはREADME、ライセンス、あるいは gitignore で初期化しないでく� さい。 これらのファイルは、プロジェクトを GitHub Enterprise Serverにプッシュした後で追� できます。 [Create New Repository] ドロップダウン
  2. ターミナルターミナルGit Bashを開いてく� さい。
  3. ワーキングディレクトリをローカルプロジェクトに変更します。
  4. ローカルディレクトリを Git リポジトリとして初期化します。
    $ git init -b main
  5. ファイルを新しいローカルリポジトリに追� します。 これで、それらのファイルが最初のコミットに備えてステージングされます。
    $ git add .
    # ローカルリポジトリにファイルを追� し、コミットに備えてステージします。 ファイルをステージから降ろすには、'git reset HEAD YOUR-FILE' を使います。
  6. ローカルリポジトリでステージングしたファイルをコミットします。
    $ git commit -m "First commit"
    # 追跡された変更をコミットし、リモートリポジトリへのプッシュに備えます。 このコミットを削除してファイルを変更するには、'git reset --soft HEAD~1' を使い、コミットしてからファイルを再度追� してく� さい。
  7. At the top of your repository on GitHub Enterprise Serverインスタンス's Quick Setup page, click to copy the remote repository URL. リモートリポジトリの URL フィールドのコピー
  8. ターミナルで、ローカルリポジトリがプッシュされるリモートリポジトリの URL を追� してく� さい。
    $ git remote add origin  <REMOTE_URL> 
    # 新しいリモートを設定する
    $ git remote -v
    # 新しいリモート URL を検証する
  9. GitHub Enterprise Serverインスタンス へ、ローカルリポジトリの変更をプッシュします。
    $ git push -u origin main
    # ローカルリポジトリの変更を、origin として指定したリモートリポジトリにプッシュする
  1. GitHub Enterprise Serverインスタンス上で新しいリポジトリを作成します。 エラーを避けるため、新しいリポジトリはREADME、ライセンス、あるいは gitignore で初期化しないでく� さい。 これらのファイルは、プロジェクトを GitHub Enterprise Serverにプッシュした後で追� できます。 [Create New Repository] ドロップダウン
  2. ターミナルターミナルGit Bashを開いてく� さい。
  3. ワーキングディレクトリをローカルプロジェクトに変更します。
  4. ローカルディレクトリを Git リポジトリとして初期化します。
    $ git init -b main
  5. ファイルを新しいローカルリポジトリに追� します。 これで、それらのファイルが最初のコミットに備えてステージングされます。
    $ git add .
    # ローカルリポジトリにファイルを追� し、コミットに備えてステージします。 ファイルをステージから降ろすには、'git reset HEAD YOUR-FILE' を使います。
  6. ローカルリポジトリでステージングしたファイルをコミットします。
    $ git commit -m "First commit"
    # 追跡された変更をコミットし、リモートリポジトリへのプッシュに備えます。 このコミットを削除してファイルを変更するには、'git reset --soft HEAD~1' を使い、コミットしてからファイルを再度追� してく� さい。
  7. At the top of your repository on GitHub Enterprise Serverインスタンス's Quick Setup page, click to copy the remote repository URL. リモートリポジトリの URL フィールドのコピー
  8. コマンドプロンプトで、ローカルリポジトリのプッシュ先となるリモートリポジトリの URL を追� します。
    $ git remote add origin  <REMOTE_URL> 
    # 新しいリモートを設定する
    $ git remote -v
    # 新しいリモート URL を検証する
  9. GitHub Enterprise Serverインスタンス へ、ローカルリポジトリの変更をプッシュします。
    $ git push origin main
    # ローカルリポジトリの変更を、origin として指定したリモートリポジトリにプッシュする
  1. GitHub Enterprise Serverインスタンス上で新しいリポジトリを作成します。 エラーを避けるため、新しいリポジトリはREADME、ライセンス、あるいは gitignore で初期化しないでく� さい。 これらのファイルは、プロジェクトを GitHub Enterprise Serverにプッシュした後で追� できます。 [Create New Repository] ドロップダウン
  2. ターミナルターミナルGit Bashを開いてく� さい。
  3. ワーキングディレクトリをローカルプロジェクトに変更します。
  4. ローカルディレクトリを Git リポジトリとして初期化します。
    $ git init -b main
  5. ファイルを新しいローカルリポジトリに追� します。 これで、それらのファイルが最初のコミットに備えてステージングされます。
    $ git add .
    # ローカルリポジトリにファイルを追� し、コミットに備えてステージします。 ファイルをステージから降ろすには、'git reset HEAD YOUR-FILE' を使います。
  6. ローカルリポジトリでステージングしたファイルをコミットします。
    $ git commit -m "First commit"
    # 追跡された変更をコミットし、リモートリポジトリへのプッシュに備えます。 このコミットを削除してファイルを変更するには、'git reset --soft HEAD~1' を使い、コミットしてからファイルを再度追� してく� さい。
  7. At the top of your repository on GitHub Enterprise Serverインスタンス's Quick Setup page, click to copy the remote repository URL. リモートリポジトリの URL フィールドのコピー
  8. ターミナルで、ローカルリポジトリがプッシュされるリモートリポジトリの URL を追� してく� さい。
    $ git remote add origin  <REMOTE_URL> 
    # 新しいリモートを設定する
    $ git remote -v
    # 新しいリモート URL を検証する
  9. GitHub Enterprise Serverインスタンス へ、ローカルリポジトリの変更をプッシュします。
    $ git push origin main
    # ローカルリポジトリの変更を、origin として指定したリモートリポジトリにプッシュする

参考リンク