.gitignoreが効かない
キャッシュ削除による解決を試みます。
git rm -r --cached .
git push がreject
ローカルが正/originであることを確認して、強制的にpushします。
git push -f origin master
git pull error マージエラーが発生
error: Your local changes to the following files would be overwritten by merge:
test.py
Please commit your changes or stash them before you merge.
Aborting
Solve it by overwriting 上書きして解決する場合
pull元が正しい前提で上書きを行います。
git fetch origin master
git reset --hard origin/master
git pull origin/master
sshで2つのgithubアカウントを管理
~/.ssh/configに2つのアカウントを記載 2つ目をサブに設定
Host github github.com
HostName github.com
IdentityFile ~/.ssh/rsa-git
User git
Host github github.com.sub
HostName github.com
IdentityFile ~/.ssh/rsa-git-sub
User git
remote URLを以下に設定
git remote add origin [email protected]:user2/repository.git
.git/configに以下の様に設定されているかを確認
[remote "origin"]
url = [email protected]:user2/repositry.git
sshにて2つのアカウントが動作することを確認
ssh -T [email protected]
Enter passphrase for key '/Users/user/.ssh/rsa-git':
Hi user1! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T [email protected]
Enter passphrase for key '/Users/user/.ssh/rsa-git-sub':
Hi user2! You've successfully authenticated, but GitHub does not provide shell access.
レポジトリ登録備忘メモ
github側
- private repository新規登録
注意点
- README.mdは作成しないこと ※Localで作成する
- defaultのブランチはmaster ではなくmainであること
- 右上のCodeからsshのURLを確認
[email protected]:username/new-rep.git
ローカル側
- ソースを管理したいディレクトリ・フォルダに移動
- git init
- git remote add origin [email protected]:username/new-rep.git
- git add .
- git commit -m “update”
- git push origin main