0
0

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 1 year has passed since last update.

Git GitHub入門個人的メモ

Last updated at Posted at 2023-02-26

最初によく使うコマンド

clone

shell
git clone {URL}

ブランチ表示

shell
git branch

ブランチ作成 => 切り替え

shell
git checkout -b {新規ブランチ名}

ブランチ削除

shell
git branch -d {削除ブランチ名}

-Dにすると強制削除

ステージング

shell
git add .

コミット

shell
git commit -m "{コミットメッセージ}"

プッシュ

shell
git push origin HEAD

HEADは現在のローカルのブランチ名になる

その他コマンド

shell
git fetch

fetchを実行すると、リモートリポジトリの最新の履歴の取得ができる。

shell
git pull

pullするとGitHubの最新の状態に更新する。

shell
git checkout {存在しているブランチに切り替え}
git checkout -b {存在していないブランチに切り替え(作成して切り替え)}

checkout の -b オプションの違い

shell
git remote add origin {GitHubでNew RepositoryしたときにでるURL}

ローカルのGitとGitHubを接続

shell
git init

現在のディレクトリをGit管理するようにする。(.gitディレクトリが作成される。)

コミットメッセージ、ブランチの命名規則

これを使う。ブランチ名はコロンの代わりにハイフンを使用する。

初期設定

SSH接続

shell
mkdir ~/.ssh && cd $_

ssh-keygen -t rsa

touch ~/.ssh/config
echo "Host *
    IPQoS=0x00" >> ~/.ssh/config

git config --global user.email {Email}
git config --global user.name {アカウント名}

cat ~/.ssh/id_rsa.pub

GitHubで
settings/SSH and GPG Keys/New SSH Keysを選択してcat ~/.ssh/id_rsa.pubの内容をコピペ

shell
ssh -T git@githuib.com

で接続を確認。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?