Open3

gitチートシート

antyuntyunantyuntyun

基本操作

リモートレポジトリ作成

codecommit

aws codecommit create-repository \
	--repository-name {repository-name} \
	--repository-description "This is repository description"

ローカルレポジトリをリモートレポジトリに登録

masterをmainに変更し、developを生やしてリモートレポジトリに登録

git init
git add .
git cm 'FirstCommit'
git branch -m master main
git cob develop
git remote add origin http://{remote-repogitory}

デフォルトブランチ変更

codecommit

デフォルトブランチをdevelopに変更

aws codecommit update-default-branch \
    --repository-name {repojitory-name}\
    --default-branch-name develop
antyuntyunantyuntyun

conflictしたときに片方のブランチを優先させる

ローカルのレポジトリとリモートレポジトリを同期させないで、featureブランチを切って作業しだしてしまうとよくこの状況になる。developが古い状態。
featureブランチにいて、git pull origin develop

Auto-merging xxx.py
CONFLICT (content): Merge conflict in template.ipynb
Automatic merge failed; fix conflicts and then commit the result.

のようになる場合の対処法。
ここで、featureブランチを優先したい場合には

(feature) git checkout --ours xxx.py

developブランチを優先したい場合には

(feature) git checkout --theirs xxx.py

とすればよい。
そのあと、

git add xxx.py
git commit

でmark as resolvedできる