Git経由でVercelにコミット

Copilot
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git init
git add .
git commit -m "初回コミット"
git branch -M main
git remote add origin https://github.com/your-username/hydroculture-app.git
git push -u origin main

※ git add . するとたくさんのWarningが出てくるが、CRLF(改行)の問題なので、気にせず進めてOK

※ git remote add originのURLはリポジトリ画面の緑色ボタン「Code」内の矢印をクリックすると、コピペできるURLが表示される

※ git pushすると
「error: failed to push some refs to 'https://github.com/xxxxx/ooooorep.git'
hint: Updates were rejected because the remote contains work that you do not
hint: have locally. This is usually caused by another repository pushing to
hint: the same ref. If you want to integrate the remote changes, use
hint: 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.」
というエラーが起きる場合は、GitHub上にすでにあるファイルが手元のファイルと衝突していることが原因

git push -u origin main --force
として強制的に上書きするのが一番簡単

GitにアップしてもVercelで反映されるまで数分かかることがある

前述

git init
git add .
git commit -m "initial commit"

fatal: unable to auto-detect email addressというエラーが出たら、
以下のコマンドでメールアドレスを登録する
git config --global user.email "your_emais@example.example"
そしてユーザー名も登録する
git config --global user.name "Your Name"
できたらもう一度 git commit -m ""する


git branch -M main

↓ はGITHUBのリポジトリのトップページに書かれているのでコピペすること
git remote add origin git@github.com:GITHUBのユーザー名/リポジトリ名.git
git push -u origin main


fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists. というエラーが出た場合は、
一度URLを確認する
git remote -v
そして打ち間違えていたら、
git remote remove origin
でURLを削除し、もう一度設定する
git remote add origin https://github.com/ユーザー名/リポジトリ名.git
そして再度
git push -u origin mainする

BACK