ドキュメントには頻繁に更新が加えられ、その都度公開されています。本ページの翻訳はまだ未完成な部分があることをご了承ください。最新の情報については、英語のドキュメンテーションをご参照ください。本ページの翻訳に問題がある場合はこちらまでご連絡ください。
記事のバージョン: Enterprise Server 2.14

このバージョンの GitHub Enterprise はこの日付をもって終了となります: このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2019-07-12. 重大なセキュリティ上の問題があっても、パッチはリリースされなくなります。優れたパフォーマンス、改善されたセキュリティ、そして新しい機能のために、GitHub Enterprise の最新バージョンにアップグレードしてください。 アップグレードに関するヘルプについては、GitHub Enterprise Support に連絡してください。

Getting changes from a remote repository

You can use common Git commands to access remote repositories.

本記事の内容:

これらのコマンドはリモートリポジトリの操作時に非常に便利です。 clone and fetch download remote code from a repository's remote URL to your local computer, merge is used to merge different people's work together with yours, and pull is a combination of fetch and merge.

リポジトリをクローンする

To grab a complete copy of another user's repository, use git clone like this:

$ git clone https://hostname/ユーザ名/REPOSITORY.git
# リポジトリを自分のコンピュータにクローン

リポジトリのクローン時は、複数の異なる URL から選択できます。 GitHubにログインした状態である間は、これらの URL はリポジトリの詳細の下に表示されます:

リモート URL リスト

git clone を実行すると、以下のアクションが発生します:

リモートリポジトリ内の各ブランチの foo と、対応するリモート追跡ブランチである refs/remotes/origin/foo がローカルのリポジトリに作成されます。 このようなリモート追跡ブランチの名前は、通常 origin/foo と省略できます。

Fetching changes from a remote repository

git fetch を使用して、他のユーザによる新たな作業成果を取得できます。 Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches.

If you already have a local repository with a remote URL set up for the desired project, you can grab all the new information by using git fetch *remotename* in the terminal:

$ git fetch remotename
# リモートリポジトリへの更新をフェッチする

または、いつでも新しいリモートを追加してその後フェッチすることもできます。

Merging changes into your local branch

マージとは、あなたのローカルでの変更を他のユーザによる変更と結合させる処理です。

Typically, you'd merge a remote-tracking branch (i.e., a branch fetched from a remote repository) with your local branch:

$ git merge remotename/branchname
# オンラインで行われた更新をローカル作業にマージする

Pulling changes from a remote repository

git pull は、git fetchgit merge を 1 つのコマンドで実行できる便利なショートカットです:

$ git pull remotename branchname
# オンライン更新をローカル作業にマージ

pull は、取得された変更のマージを実行するため、pull コマンドの実行前にローカルの作業がコミットされていることを確認する必要があります。 解決できないマージコンフリクトが発生した場合、あるいはマージを中止したい場合は、git merge --abort を使用して、プルを行う前の状態にブランチを戻すことができます。

参考リンク

担当者にお尋ねください

探しているものが見つからなかったでしょうか?

弊社にお問い合わせください