akane_memo

これからがんばるための勉強メモ、じぶん用

Gitでリモートリポジトリにcommitしてpushする方法

$から始まるやつはターミナルで実行する

$ git add .
$ git commit -m 'commit commentを書く'
$ git push

でpushできる

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@hogehogehogehoge.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

みたいなエラーが表示された場合は、commitが干渉しているので先にpullしてからpushする

$ git pull
$ git push
Counting objects: 24, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 11.68 KiB, done.
Total 18 (delta 4), reused 0 (delta 0)
To git@hogehogehogehoge.git
   91090a7..74f5250  master -> master

みたいに表示されたらオッケー