LoginSignup
0
0

More than 1 year has passed since last update.

Git を使うたための初期設定(windows クライアント → Linux サーバ)

Posted at

注意

Linux の細かい操作方法やインストール方法は説明していません。

サーバ側

git のインストール

# yum install git

リモートリポジトリの作成

$ cd /home/user/
$ mkdir ~/git_repo.git
$ git init --bare --share

クライアント側(windows)

git のインストール

windows の git を以下の URL からダウンロードします。
https://gitforwindows.org/
インストール方法はここでは説明しませんが、全て「はい(YES)」で良いかと思います。

リモートリポジトリの追加

コマンドプロンプトを開き以下を実行します。
「git config --global --edit」では適宜名前と E メールアドレスを設定する。

C:\USER\USER>cd /Documents/<使いたいフォルダ>
C:\USER\USER>git init
C:\USER\USER>git config --global --edit
C:\USER\USER>git add .
C:\USER\USER>git commit -m "first commit"
C:\USER\USER>git remote add origin user@<サーバの IP アドレス>:~/git_repo.git

結果の確認

以下のような結果が帰って来ることを確認します。

C:\USER\USER>git remote -v
origin  user@<サーバの IP アドレス>:~/git_repo.git (fetch)
origin  user@<サーバの IP アドレス>:~/git_repo.git (push)

クライアントから push してみる

C:\USER\USER>git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 304 bytes | 152.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
To <サーバの IP アドレス>:~/git_repo.git
   458c2e8..6b7a273  master -> master

サーバ側で確認してみる

$ git log
commit 6b7a273822948d060e8133cdb3d3a133cba6aab3
Author: user <user のメールアドレス>
Date:   Mon May 1 09:45:02 2022 +0900

    first commit

ここまで設定できれば VSCode などでも使用できる状態になります。

0
0
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
0
0