Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save 3panda/b24729e793e0224332672c3d721118ae to your computer and use it in GitHub Desktop.

Select an option

Save 3panda/b24729e793e0224332672c3d721118ae to your computer and use it in GitHub Desktop.
GitHub 利用準備と操作の基本まとめ

GitHub 利用準備と操作の基本まとめ

1. GitHub アカウント作成

  • https://github.com/ にアクセスしてアカウント作成
  • ユーザー名、メールアドレス、パスワードを登録

2. Git のインストールと初期設定

macOS(Homebrew経由がおすすめ)

brew install git

Gitのバージョン確認とパス確認

git --version
which git

Git のユーザー設定(グローバル)

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

3. エディタ設定(VS Code を使用する場合)

git config --global core.editor "code --wait"
  • --wait を付けることで、VS Code を閉じるまでGitが待機するようになる

4. グローバル .gitignore 設定(Neovimユーザー向け)

touch ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

.gitignore_global の内容例

*.swp
*.swo
*.swx
*.un~
*.bak
*~
nvim-log.txt
.cache/

5. SSHキーの生成とGitHubへの登録

SSHキー生成

ssh-keygen -t ed25519 -C "your_email@example.com"

(保存先はデフォルトの /Users/yourname/.ssh/id_ed25519 でOK)

公開鍵をGitHubに登録

pbcopy < ~/.ssh/id_ed25519.pub
  • GitHub → Settings → SSH and GPG keys → New SSH Key に貼り付け

接続確認

ssh -T git@github.com

6. 確認用リポジトリの作成

おすすめのリポジトリ名

  • env-check
  • setup-check
  • dev-env-test

Description 例

  • Repository for verifying development environment setup.

7. Git 操作の基本

新しいリポジトリのクローン

git clone git@github.com:yourname/repo-name.git
cd repo-name

ブランチ作成と切り替え

git switch -c testbranch

変更・追加・コミット・プッシュ

git add .
git commit -m "Initial commit"
git push -u origin testbranch

8. エラー時の対処法

error: src refspec does not match any

→ ブランチが存在しない。作成して切り替えてから push

git switch -c testbranch
git push -u origin testbranch

error: failed to push some refs

→ リモートに先に変更がある。以下で対応:

git pull --rebase origin ブランチ名
git push

9. GitHub Web UI で履歴を見る方法

  1. リポジトリページを開く
  2. Code タブの上部にある「コミットメッセージ」や「X commits」リンクをクリック
  3. 個別ファイルの変更履歴は、ファイル表示ページで右上の History をクリック
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment