11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git リモート操作

Posted at

リモートリポジトリの内容をローカルリポジトリに取得(マージしない)

# git fetch [リモートリポジトリURL|リモートリポジトリ名]
コマンド例
# git fetch file:///opt/repos/git_test.git
	From file:///opt/repos/git_test
	 * branch            HEAD       -> FETCH_HEAD

リモートリポジトリの内容をローカルリポジトリに取得(マージする)

# git merge FETCH_HEAD
コマンド例
# git fetch file:///opt/repos/git_test.git
	From file:///opt/repos/git_test
	 * branch            HEAD       -> FETCH_HEAD
# git merge FETCH_HEAD
	Updating 70ff494..708600b
	Fast-forward
	 date.txt |    1 +
	 1 files changed, 1 insertions(+), 0 deletions(-)

リモートリポジトリの内容をローカルリポジトリに取得(マージする)

# git pull [リモートリポジトリURL|リモートリポジトリ名]
コマンド例
# git pull file:///opt/repos/git_test.git
	remote: Counting objects: 5, done.
	remote: Compressing objects: 100% (2/2), done.
	remote: Total 3 (delta 0), reused 0 (delta 0)
	Unpacking objects: 100% (3/3), done.
	From file:///opt/repos/git_test
	 * branch            HEAD       -> FETCH_HEAD
	Updating 70ff494..708600b
	Fast-forward
	 date.txt |    1 +
	 1 files changed, 1 insertions(+), 0 deletions(-)

リモートリポジトリとローカルリポジトリの差分表示

# git diff HEAD FETCH_HEAD

--- 作業例 ---

  1. リモートリポジトリの内容をローカルリポジトリに取得(マージしない)
  2. 差分表示
コマンド例
# git fetch file:///opt/repos/git_test.git
	From file:///opt/repos/git_test
	 * branch            HEAD       -> FETCH_HEAD
# git diff HEAD FETCH_HEAD
	diff --git a/date.txt b/date.txt
	index 377cd4e..31c4c67 100644
	--- a/date.txt
	+++ b/date.txt
	@@ -1 +1,2 @@
	 Sat Nov 23 05:46:22 JST 2013
	+Sat Nov 23 06:54:13 JST 2013

ローカルリポジトリの内容をリモートリポジトリへ送信

# git push [リモートリポジトリURL|リモートリポジトリ名] [ローカルブランチ名]

--- 作業例 ---

  1. ファイルの修正
  2. ステージング
  3. コミット
  4. リモートリポジトリへ送信
コマンド例
# echo $(LANG=C;date) >> date.txt
# git add date.txt
# git commit -m 'message 3' date.txt
	[master 45d530d] message 3
	 1 files changed, 1 insertions(+), 0 deletions(-)
# git push file:///opt/repos/git_test.git master
	Counting objects: 3, done.
	Writing objects: 100% (3/3), 232 bytes, done.
	Total 3 (delta 0), reused 0 (delta 0)
	Unpacking objects: 100% (3/3), done.
	To file:///opt/repos/git_test.git
	 * [new branch]      master -> master
11
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?