LoginSignup
0
2

More than 1 year has passed since last update.

【備忘録】ローカルリポジトリの内容をリモートリポジトリにpushするまで

Posted at

【Gitの登録】

1. ユーザー名を登録

$ git config --global user.name <username>

2. メールアドレスを登録

$ git config --global user.email <emailaddress>

3. 登録内容を確認

$ git config --global --list

【ローカルにプロジェクトファイル作成(Linuxの場合)】

Ubuntu上で実行する

1.ディレクトリを作成する場所まで移動

$ cd /var/www/html

2.テストディレクトリ作成

$ mkdr test

3.テストファイルを作成

$ sudo git init

【リモートリポジトリに上げたい新規ファイルを作成】

  1. テストディレクトリに新規ファイルを作成
    $ sudo touch test.txt
  2. 現在のリポジトリ内のステータス状況を確認
    $ git status
  3. testファイルをステージングに追加
    $ sudo git add hello.txt
  4. ステージングにあるtestファイルをローカルリポジトリに追加
    git commit -m 'first commit'

【リモートリポジトリを作成】

1.Githubにログイン
2.管理画面よりリモートリポジトリを作成
2022-10-19.png
右上の「+」ボタンを押下し、「New repository」よりリモートリポジトリを新規作成

リポジトリ名(Repository name)をtest、説明(Description)を「テストです。」とし、「Create repository」ボタンを押下すとリモートリポジトリが出来上がる。

【リモートリポジトリに接続する】
1.Gitとリモートリポジトリを紐づける
$ git remote add test(リモートリポジトリ名) git@github.com:[ここにはアカウント名が入ります]/test.git(リモートリポジトリURL)
※リモートリポジトリURLはリモートリポジトリ作成時に表示されています。
2022-10-19 (1).png
2.ブランチ名をmainに変更する(しなくてもよい)
sudo git branch -M main
2. ローカルリポジトリの内容をリモートリポジトリにPush
$ git push test main

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