git の基本操作

作業が終わったら pull request する

①構文チェックをする
$ npm run lint

②main branch から派生させた feature branch をつくる
$ git checkout main
$ git checkout -b feature/20221114-issue-name

③commit する
$ git status
$ git add <fileName>
$ git commit -m 'comment'

④push する
$ git push origin feature/20221114-issue-name

⑤Github上で pull request を作成する

main が更新されたら pull する

$ git checkout main
$ git pull

local に sub branch を持ってくる

$ git checkout main
$ git fetch
$ git checkout -b feature/20221114-test origin/feature/20221114-test

remote の sub branch が更新されたら pull する

$ git pull origin feature/20221114-test:feature/20221114-test

トラブル

pull request 中に、main が自分のブランチより進んでいたら

$ git checkout main
$ git pull
$ git checkout feature/20221125-admin
$ git merge main

# GNU nano で 保存 [Ctrl + o] → 終了 [Ctrl + x]
$ git push origin feature/20221125-admin

CONFLICT が発生したら

手動で conflict を解消してから以下。

$ git add <CONFLICTが解消されたファイル>
$ git rebase --continue あるいは $ git merge --continue
   :  viで履歴を編集する画面が出るので何もせず終了
$ git push origin <自分のブランチ>

CONFLICT で pull ができないときに強制的に pull するには

$git fetch origin
$git reset --hard origin/main
$git pull

※ただし修正したものは全部消えます!

ところが permission denied で困った場合は

sudo chown [ユーザ名] -R ./
sudo chgrp [ユーザ名] -R ./


投稿日

カテゴリー:

投稿者:

タグ: