Open3
gitチートシート
基本操作
リモートレポジトリ作成
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
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できる
歴史上から特定ファイルの存在をなかったことにする
testディレクトリ以下のtest.txtの場合は例えば以下
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch test/test.txt " --prune-empty -- --all
以下参照