LoginSignup
0
0

More than 3 years have passed since last update.

よく使うGitコマンドを書いてみた(随時更新中)

Last updated at Posted at 2020-07-15

はじめに

これは未経験エンジニアが、フルスタックエンジニアになるための備忘録である:point_up:

よく使うコマンド一覧

ディレクトリでgitを使い始めるためのコマンド

git init
//リポジトリしたいファイルにgit init

作成したリポジトリをローカルにコピーする

git clone SSHまたはHTTPSのGitHubにある文字列
//リモートからローカルにコピーするコマンドですね!  

現在gのgitの状態を確認する

git status
//赤字で表示されたら管理外 緑色ならば管理されている状態(ステージング状態)
//ファイル変更したら後に実行するとmodified file名 と表示される

ファイルをgitに管理(ステージング状態)にする

git add ファイル

git add .
//全てのファイルを git したい場合

現在の状態をgitにコミットメッセージを残してセーブする

git commit -m "何か文字を入れてね"
//コマンドを実行したら現在の状態が git に保存される

git のコミット履歴を確認できるコマンド

git log 
//何時何分に誰が変更したかを表示してくれる

リモートにアップロードを行う

git push origin
//origin というのはリモートサーバのこと

リモートリポジトリに接続確認
鍵認証用

 ssh -T git@github.com
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nTmki6kXUpJJUDNE1IGOCspRomTxdCHYSviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
//が表示されたらyes と入力し、returnキーを押してください

Hi (自分のアカウント名) You've successfully authenticated, but GitHub does not provide shell access.
このように表示されたら接続は成功
$ git remote add origin git@github.com:アカウント名/リポジトリ名.git
$ git push -u origin master

画面に以下のようなメッセージが表示されたらpushは完了。

Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 420 bytes | 420.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To github.com:BabaShun/sample.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
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