LoginSignup
0
0

More than 1 year has passed since last update.

【Git】git push -u origin masterしたら、error: failed to push some refs to 'https://github.com/ユーザー名/リポジトリ名.git'と怒られたときの対処法

Posted at

症状

pushしたかったディレクトリではなく、一つ下位のディレクトリでpushまでしてしまいました。
再度、pushしたかったディレクトリで設定しなおして、pushしたところ下記のエラーが表示されてしまいました。

ターミナル
git push -u origin master
git: 'credential-cache' is not a git command. See 'git --help'.
To https://github.com/ユーザー名/リポジトリ名.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/TKWebSE/near-eats.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

エラー文章を翻訳すると、
「エラー:一部の参照を「https://github.com/ユーザー名/リポジトリ名.git」にプッシュできませんでした」

ヒントを翻訳すると、
「ヒント:リモートにあなたが行った作業が含まれているため、更新は拒否されました」
「ヒント:ローカルにはありません。これは通常、別のリポジトリがプッシュすることによって発生します」
「ヒント:同じ参照に。最初にリモートの変更を統合することをお勧めします」
「ヒント:(例: 'git pull ...')もう一度押す前に。」
「ヒント:詳細については、「gitpush--help」の「早送りに関する注意」を参照してください。」
と書いてありました。

解消方法

以下コマンドで、リモートリポジトリを削除し、新たい作成することができました。
とはいえ、このコマンドを使用する際にはいくつか注意点が必要です。
現在のプロジェクトのバックアップをしたのにち実装すると良いでしょう。

ターミナル
git push -f origin master

参考

https://www.atlassian.com/ja/git/tutorials/syncing/git-push
GitHubにpushする時にerror: failed to push some refs と表示されてpushできない時
https://qiita.com/kazuki0714/items/ceda3a6721a9a99082de

0
0
1

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