0
0

【git】リモートブランチで更新かけてローカルブランチでコミットしてプッシュしたら・・・

Last updated at Posted at 2024-08-17

はじめに

gitでかなり横着したら少しハマった・・・
リモートブランチでREADME.mdをgithub上から更新をかけて、
そのことを忘れていて普通にローカルブランチで作業してコミットしてプッシュしようとしたらgitにプッシュできないと怒られた。

ブランチ関係.txt
develop -> origin develop

これをリモートブランチの更新をローカルブランチに取り込みつつローカルブランチのコミットも維持してリモートブランチを更新する方法を備忘録として残しておく。

エラー内容

error.txt
From https://github.com/sample/hogehoge * branch develop -> FETCH_HEAD 
hint: You have divergent branches and need to specify how to reconcile them. 
hint: You can do so by running one of the following commands sometime before
hint: your next pull: 
hint: 
hint: git config pull.rebase false 
# merge hint: git config pull.rebase true 
# rebase hint: git config pull.ff only 
# fast-forward only 
hint: 
hint: You can replace "git config" with "git config --global" to set a default 
hint: preference for all repositories. You can also pass --rebase, --no-rebase, 
hint: or --ff-only on the command line to override the configured default per hint: invocation. 
fatal: Need to specify how to reconcile divergent branches.

解決方法

resolve.txt
git fetch
git merge origin/develop
git push origin develop

ローカルリポジトリにあるリモートブランチ情報を更新してローカルブランチにリモートブランチをマージすることでうまくいったみたいだ。
コレでプッシュもできた。

まとめ

地味にだるいなぁ。
でも便利なgit。

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