git command - 42tokyo-minishell/42_minishell GitHub Wiki
よく使うgit command memo
branch
-
右下 Development -> Create a branch で Issue に紐づいた branch ができる remote の branch を local に反映
git fetch git checkout 3-github-test
-
ローカルでブランチ作成、リモートに反映
# new_branch作成元のbranchに移動(大体main?) git checkout <branch_name> # branchを作成 git checkout -b <new_branch_name> # リモートに登録 git branch -u origin <new_branch_name>
-
remoteとの差分をlocalに反映
git fetch --prune
stash
- https://codelikes.com/git-stash/
- stashでコンフリクトしたとき:--ours .
rebase
- 何個か前の commit 内容を変更したい時
git log --oneline # 変更したい commit の 1個以上前を選んで git rebase -i HEAD~2(先頭から何個前か) or [onelineの左のhash] # 変更したい commit の左を edit にするだけして閉じる # コードの内容を変更する、commit message を変更する git commit --amend git add [addするやつ] git rebase --continue git push -f origin [branchname]