macやubuntuからgitにpushするときにつまずいた事
2151 ワード
初かきこ...
~ubuntuとmacでgithubの同じリポジトリを共有した時につまずいたことを記録~
(1)mac側のvscodeでローカルリポジトリをいじくりまわしてプッシュしようとしたら失敗した。
今思うとpullとpushの押し間違いなのではないかと信じたい。
いろいろ試したが、これといった決定打はない。
最終的にはpushはできた。
(2)mac側とWSLのubuntu側に同時にリモートリポジトリからローカルリポジトリを作成し、mac側で色々gitにpushする。次にubuntu側でいろいろ作業してpushすると失敗。
ubuntu側からpushできない。
$git push
error: Your local changes to the follwing files would be overwritten by merge:
a.py
Please commit your changes or stash them before you merge.
Aborting
まずはa.pyをステージング、コミット、プッシュ(失敗)、プル
$git add a.py
$git status
ブランチ master
Your branch and 'origin/master' have diverged,
and have 〇〇 and 〇〇 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
コミット予定の変更点:
(use "git restore --staged <file>..." to unstage)
modified: a.py
$ git commit -m "a.pyの変更。など適当に記入しておく"
[master 〇〇] a ubuntu
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 〇〇 => 〇〇 a.py
$ git push
Username for 'https://github.com': 自分の登録名
Password for 'https://〇〇@github.com': 登録してるパスワード
To https://github.com/〇〇.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/〇〇.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
$ git pull
Username for 'https://github.com': 自分の登録名
Password for 'https://〇〇@github.com': 登録してるパスワード
これでなんとかリモート側とローカル側のリポジトリの同期が完了し、なんとかなった。
Author And Source
この問題について(macやubuntuからgitにpushするときにつまずいた事), 我々は、より多くの情報をここで見つけました https://qiita.com/tata04/items/5726e2f1ca77620ad4ac著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .